Save Output in java...

Discussion in 'Mac Programming' started by Vasileios, Nov 22, 2005.

  1. macrumors regular

    Vasileios

    Joined:
    Oct 28, 2005
    Location:
    Greece
    #1
    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...
     
  2. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #2
    Can we have more info on what you're doing and trying to do please?
     
  3. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    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?
     
  4. thread starter macrumors regular

    Vasileios

    Joined:
    Oct 28, 2005
    Location:
    Greece
    #4
    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...
     
  5. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
  6. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #6
    Even simpler than adding to your code - run in command line with '>' i.e.:

    java -cp . MyClass > result
     
  7. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #7
    Guess that would work too. But I figured he was asking how to code it since it is a programming forum category.
     
  8. macrumors 601

    Compile 'em all

    Joined:
    Apr 6, 2005
    #8
    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.
     

Share This Page