Results 1 to 6 of 6
  1. #1
    Iskatel is offline Member
    Join Date
    Mar 2010
    Posts
    27
    Rep Power
    0

    Default Save the output from system.out.println into a file

    Hi all,

    I am wondering if it is possible to save print outs from system.out.println into a file. I am using a third party code that outputs such prints, when I use it from command line I use: C:\\someCommand someOptions inputFile > outputFile
    I don't want to mess about with the third party code, I just wonder whether I can implement something similar to ">" in the command line. In the Java code, I make an instance and call the run program of that instance with some parameters, so it just gives some printouts.

    Thanks,
    Iskatel.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    Java Code:
    System.setOut(new PrintStream(new File("outputFile")));
    the command line parameter can be found in the array of the main method :p

  3. #3
    Iskatel is offline Member
    Join Date
    Mar 2010
    Posts
    27
    Rep Power
    0

    Default

    Hmm, thank you very much, I guess this should have gone to the beginners section :). I removed the main method and was using the class instance directly. Thank you again!

  4. #4
    Iskatel is offline Member
    Join Date
    Mar 2010
    Posts
    27
    Rep Power
    0

    Default

    How do I set it back to normal? I tried System.setOut(System.out) doesn't work.

  5. #5
    Iskatel is offline Member
    Join Date
    Mar 2010
    Posts
    27
    Rep Power
    0

    Default

    Done, should have saved it first PrintStrim ps = System.out; then System.setOut(ps).
    Thanks.

  6. #6
    Iskatel is offline Member
    Join Date
    Mar 2010
    Posts
    27
    Rep Power
    0

Similar Threads

  1. Replies: 5
    Last Post: 08-03-2012, 11:47 AM
  2. System.out.println
    By JohnDoe in forum New To Java
    Replies: 1
    Last Post: 09-05-2010, 11:14 AM
  3. System.out.println(040|343);
    By satheshshiva in forum New To Java
    Replies: 5
    Last Post: 06-26-2010, 11:26 PM
  4. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 09:52 AM
  5. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-19-2008, 12:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •