0

Firstly, sorry the question is not phrased well.

I am wondering if there is a was of a java program to automatically store what the program prints out in a text file.

example:

 public static void main(String[] args) {
    System.out.println("Hello World!");
    }
}

How would I get the program to save what is printed in the console, in this case "Hello World!" to appear in a text file, for instance in notepad.

Any help is appreciated Thanks!

1 Answers1

0

If you are using Linux/Unix you could copy stdout to file using tee

See :How to redirect output to a file and stdout

Otherwise use log4j to write into a log file.

Community
  • 1
  • 1