Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What exactly is System.in?

 
Ernest Lee
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The System.in is declared as
"public static final InputStream in"...
but InputStream is an abstract class so it cannot be instaniated... so.. what is System.in?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in fact System.in is initialized with the static member in of FileDescriptor (FileDescriptor.in).
In the System class, in is further initializedas a FileInputStream wrapped around that FileDescriptor

As you can see, System.in is a BufferedInputStream wrapped around a FileInputStream which in turn wraps a FileDescriptor...
You don't really need to know what type is System.in of, but it's good practice to look inside the sources...
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic