PDA

View Full Version : Save Output in java...




Vasileios
Nov 22, 2005, 11:31 PM
Is there a way that i can save all the output that i have on the screen(Numbers and text) into a text file?
Thanks...



plinden
Nov 23, 2005, 12:09 AM
Can we have more info on what you're doing and trying to do please?

HiRez
Nov 23, 2005, 12:14 AM
Is there a way that i can save all the output that i have on the screen(Numbers and text) into a text file?
Thanks...Need a bit more information. What is the format of your Java app? Is your app being run from the command-line and where the numbers and text are being printed to the console, or do you have a graphical app where they are they in UI objects like tables and text fields?

Vasileios
Nov 23, 2005, 05:09 AM
it's a simple quess game...
the results (the number you enter-if you quess is too low, or too hight, the choice to play again etc.) are printed in the console... no grafics at all... just text...

jeremy.king
Nov 23, 2005, 08:54 AM
http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileWriter.html

or

http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html

plinden
Nov 23, 2005, 12:21 PM
Even simpler than adding to your code - run in command line with '>' i.e.:

java -cp . MyClass > result

jeremy.king
Nov 23, 2005, 12:40 PM
Even simpler than adding to your code - run in command line with '>' i.e.:

java -cp . MyClass > result

Guess that would work too. But I figured he was asking how to code it since it is a programming forum category.

Compile 'em all
Dec 2, 2005, 05:23 AM
it's a simple quess game...
the results (the number you enter-if you quess is too low, or too hight, the choice to play again etc.) are printed in the console... no grafics at all... just text...

Probably in your program you are using System.out.println() to write text to
the console. Instead use FileWriter to write to a file. As a MacRumors fellow
pointed out, take a look at Java I/O docs on SUN's website.