I've tried to temporarily redirect System.out to /dev/null using the following code but it doesn't work.
System.out.println("this should go to stdout");
PrintStream original = System.out;
System.setOut(new PrintStream(new FileOutputStream("/dev/null")));
System.out.println("this should go to /dev/null");
System.setOut(original);
System.out.println("this should go to stdout"); // This is not getting printed!!!
Anyone have any ideas?