Friday, February 10, 2017

Java - redirect standard output stream to file

Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart

 We can redirect all System.out.println output to a file with below code snippet.

 System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("/tmp/output.txt"))));

No comments:

Post a Comment

Latest Posts