How about System.setOut(PrintStream)? You can insert this call into the initialization part of your program (start).
There used to be a commment:
And of course, you can do the same with System.err - namely System.setErr (PrintStream), but better for a different file stream.
Details of the proposed autofill adding and buffering stream:
String file = ...;
PrintStream ps =
new PrintStream(true, new BufferedOutputStream(new FileOutputStream(file, true)));
System.setOut(ps);
source
share