Sometimes you wish to sent the output/error code to null device. The code snippet below shows how to do it on Unix and on Windows.

Java Code:
// Unix style
PrintStream nps = new PrintStream(new FileOutputStream("/dev/null"));
System.setErr(nps);
System.setOut(nps);

//Windows style
PrintStream nps = new PrintStream(new FileOutputStream("NUL:"));
System.setErr(nps);
System.setOut(nps);