Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing to File?

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again.

I know that if i have some loop, for example, i can prints something out e.g. elements in an array, to the screen. Is it possible to instead printing these elements to the screen, print to a text file???

BAsically, is there a way to print to a file as oppsed to the screen?

Thank you!
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Considers the System.out as a Stream so is a File. Create a BufferedWriter with FileOutputStream and it will print the data to a file. See API for more help on these. Is should be simple. Tell me if you face trouble
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should check out the I/O Trail from the Java tutorial (see link in my sig). This should help you understand how writing to a file is similar to writing to the screen (at least if you have been using the I/O Stream API already).

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic