What is an InputStreamReader
object good for?
Reading a stream of input data.
An InputStreamReader
object reads data from some source
(such as System.in).
However, it is awkward to use by itself.
A BufferedReader
object is easier to use,
but needs to be connected to an InputStreamReader
.
Look at these two lines from the program:
InputStreamReader inStream = new InputStreamReader( System.in ) ; BufferedReader stdin = new BufferedReader( inStream );
The first line constructs an InputStreamReader
object and
gives it the name inStream
.
The second line constructs a BufferedReader
object
and connects it to inStream
.
The BufferedReader
is called stdin
.
To create a BufferedReader
the new
operator is used:
BufferedReader stdin = new BufferedReader( inStream );
The new
operator
creates a BufferedReader
object out of main memory.
The BufferedReader
object can then be used to do input.
"BufferedReader" appears twice in this statement
because the first "BufferedReader" describes the type of the variable stdin
,
while the second one tells the new
opeator what type of object to create.