I have a simple piece of code that outputs console text to a text file in Java:
PrintStream out = new PrintStream(new FileOutputStream("test2_output.txt"));
System.setOut(out);
However I require this text file to contain the error messages that is produced in the console but they are not included.
How do I do this?
Add:
System.setErr(out);
at the end.
There is also a System.setErr()
call to redirect stderr.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With