Monday, 25 April 2016

How to redirect standard output stream to a file ?


Use System.setOut

Example
try {
    System.setOut(new PrintStream("src/java.txt"));
    System.out.println("hello");
} catch (FileNotFoundException e1) {
    e1.printStackTrace();

}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.