The moose likes Beginning Java and the fly likes about nullPrintStream class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about nullPrintStream class" Watch "about nullPrintStream class" New topic

about nullPrintStream class

Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
in which package can i find the nullPrintStream class .which package i have to import to instantiate that class

thanks and regards<br />Santhi Bharath<br />SCJP 5.0, SCWCD 5.0
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
There's no such class in the JDK. Must be in your own code, or some third-party code you are using. For the former, grep your source code. For the latter, try Google.

By the way, the name is probably NullPrintStream, not nullPrintStream. Case matters, in Java. If the name really is nullPrintStream, it is an unconventional (i.e. legal, but bad) class name.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
public final static InputStream in = nullInputStream();

public final static PrintStream out = nullPrintStream();

these two are the declarations of "in" and "out" fields in System class

i have copied from the System class definiton file from src of jdk1.5.0

while i am searching in google for nullInputStream class,i have found different third party packages like


can you explain what this party packages and where can i found it in jdk src files and i couldn't found any class NullInputStream in jdk1.5.0 src files.
Joanne Neal

Joined: Aug 05, 2005
Posts: 3429
nullInputStream is not a class, it's a method in the System class.

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
And, looking at the source of the System class, they're very strange methods, too. See the comment above them: -

I don't think there's much to be gained by looking into the detail of these methods. They just look like some nasty hack needed for the special requirements of initialisation of this internal Java implementation class.

If you're looking for a PrintStream that writes to a null device, these System methods do not do that. You're better off looking at one of the examples you already found on the Web.
Don't get me started about those stupid light bulbs.
subject: about nullPrintStream class
Similar Threads
How does System.out.println() work?
out member
How does "system.out.print" internally work