
Signature
Daniel Dyer
http://www.dandyer.co.uk
...
>> A lesser problem is that when I tried it, it sure threw the exception:
...
>> class Roska { public static void main(String [] args) {
>> System.setOut(null);
>> System.out.println("Hello?");
>> }}
...
> It's not surprising, you are dereferencing a null.
It's not just System.out = null; and while the docs say setOut
'reassigns the "standard" output stream', they don't say that it
simply reassigns it to its argument as is.
> There are three alternatives that come to mind:
>
> 1). Don't use System.out, but I guess if that were viable you
> wouldn't be asking.
(The one asking was somebody else. I was just curious about a claim
that System.setOut(null) would, maybe, work, so I tried.)
> 2). Redirect stdout to /dev/null outside of the VM:
>
> java MyClass > /dev/null
>
> 3). Create a sub-class of PrintStream that discards everything and
> use setOut to point to that.
The winning way so far appears to be to subclass OutputStream so, and
pass the resulting OutputStream to the appropriate PrintStream
constructor. It's in another branch of this thread already, after I
had suggested your number 3.
Daniel Dyer - 27 Nov 2006 16:56 GMT
>> There are three alternatives that come to mind:
>>
[quoted text clipped - 15 lines]
> constructor. It's in another branch of this thread already, after I
> had suggested your number 3.
My apologies, I seem to have missed the other branch of this thread,
didn't mean to be redundant.
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk