Pages

Java IO Package

Java Inputstream. Outputstream

his package contains the input/output facilities (i.e classes) that are used to read input or write output

Stream.

A stream is a collection of memory cells.

A stream is connected to a data source or a device like  a file, keyboard, network computer, monitor, printer

A stream is the mediator between the datasource/device   and a program, i.e the program reads data from the stream or the program writes the data to the stream.
Inputstream.

The stream from which the program reads the data is called inputstream

outputstream.

The stream to which the program writes data is called output stream
Streams in java.
Streams in java are objects of the relevant stream classes.

for example

BufferedInputStream is a stream class

BufferedOutputStream is a stream class

BufferedInputStream bis;

BufferedOutputStream bout; 

bis and bout are objects (stream objects).
All stream classes are a part of "java.io" package

 

Types of streams

There are two types
(i) Byte streams
(ii)Character streams
Byte streams are used to read and write binary data (8 bits data)

Character streams are used to read and write character data (supports reading and writing 16 bits character data)

The super classes of Byte stream category

InputStream  and  OutputStream

The super classes of character stream category

Reader    and Writer

few class names

BufferedReader
BufferedWriter
FileReader 
FileWriter
BufferedInputStream 
FileInputStream
FileOutputStream


the input stream "System.in" is connected to k/b.

the "InputStreamReader" class. Object of this class is used convert bytes to characters.

the "BufferedReader" class. This is the subclass of "Reader" used to read from buffer.

No comments:

Post a Comment