// discard all output to System.out and System.err PrintStream discard = new PrintStream( new NullOutputStream() ); System.setOut( discard ); System.setErr( discard );
You could knock off the trivial code for NullOutputStream yourself or get it from Apache Commons source.
This technique is more efficient than writing to the NUL device, since no bytes are sent to the OS (Operating System), and there is no buffering overhead.
// discarding output on windows, note "nul" with one l. System.setOut( new PrintStream( new File( "nul" ))); // discarding output on Unix, note null with two ls. System.setOut( new PrintStream( new File( "/dev/null" )));Thanks go to John B. Matthews for the information.
This page is posted |
http://mindprod.com/jgloss/discardingoutput.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\discardingoutput.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.224.73.157] |
| |
Feedback |
You are visitor number | |