Java – system Setout redirects back to standard output
•
Java
System. Setout redirects standard output For example,
FileOutputStream f = new FileOutputStream("file.txt"); System.setOut(new PrintStream(f));
Each system out. Print will be written to this file My question is, once completed, how do I set the output back to standard?
Solution
Just save and restore it:
final PrintStream oldStdout = System.out; System.setOut(newStdout); // ... System.setOut(oldStdout);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码