title: In Java, how can I redirect System.out to null then back to stdout again?
body: <p>I've tried to temporarily redirect System.out to /dev/null using the following code but it doesn't work.</p>
  
  <pre><code>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!!!
  </code></pre>
  
  <p>Anyone have any ideas?</p>