Showing posts with label null. Show all posts
Showing posts with label null. Show all posts

16 February 2013

Make System.out to write to Null OutputStream

Sometimes we have our app have System.out.println in many places in the app.

We can make the System.out to write to empty (Null) output stream.

At the entry point of the app, use the following code:


System.setOut(new PrintStream(new OutputStream() {
public void write(int b) throws IOException {
}
}));