wood burning stoves
The moose likes I/O and Streams and the fly likes Finding the type of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Finding the type of "System.in"" Watch "Finding the type of "System.in"" New topic

Finding the type of "System.in"

Ameet Parande

Joined: Sep 10, 2003
Posts: 7
In java.lang.System it is defined as a reference to the "InputStream" interface.
On printing it - using a simple print like so:
System.out.println( System.in );
it says it is of type "java.io.BufferedInputStream".
But BufferedInputStream is a decorator - I want to know who is the decoree.
Examaning the class object or using instanceof to does not help since the decoree is contained in the decorator.
Can anyone suggest a way I can find out the type of System.in?
Thanks in advance.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Why do you want to know? It's going to be a non-public class, in any event.

[Jess in Action][AskingGoodQuestions]
Ameet Parande

Joined: Sep 10, 2003
Posts: 7
I was under the impression that it would wrap one of the polular public class from java.io like: ByteArrayInputStream / PipedInputStream etc..
I am not stuck with a problem or anything, I was plainly curious of the implementation of: System.out and System.in :-)
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
You can download the source code for the SDK and peruse through the .java files if you are interested. I do that myself every now and then when bored or curious of how things are really implemented under the hood.
It's nice not having to worry about implementation details, but it is sometimes fun to find them out!
subject: Finding the type of "System.in"
It's not a secret anymore!