"Anthony Borla" <ajborla@bigpond.com> wrote on Sun, 30 Nov 2003
00:13:51 GMT in comp.lang.java.help:
>> Is there a way to assign System.err so that messages
>> are discarded? I tried assigning it to null, which compiles,
[quoted text clipped - 11 lines]
> PrintStream nps = new PrintStream(new FileOutputStream("NUL:"));
> System.setErr(nps);
Or this should work on any platform:
System.setErr(new PrintStream(new OutputStream() {
public void write(int b) {}
}));

Signature
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net
Anthony Borla - 30 Nov 2003 05:21 GMT
> "Anthony Borla" <ajborla@bigpond.com> wrote on Sun, 30 Nov 2003
> 00:13:51 GMT in comp.lang.java.help:
[quoted text clipped - 22 lines]
> public void write(int b) {}
> }));
Yes, indeed, it does, it effectively discards everything sent to it, fully
meeting the OP's requirements, and is quite portable to boot. I think I was
stuck in 'bit bucket' mode :) !
Cheers,
Anthony Borla
>>Is there a way to assign System.err so that messages
>>are discarded? I tried assigning it to null, which compiles,
[quoted text clipped - 33 lines]
> // Restore old stream
> System.setErr(ops);
Thanks Anthony
Exactly what I needed!
Ron