--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD - IT)
Contact : 7600044051
E-mail : rupareleducation@gmail.com
Programming With Java
What is Stream?
Java performs I/O through Streams. A Stream is linked to a
physical layer by java I/O system to make input and output operation in java.
In general, a stream means continuous flow of data. Streams are clean way to
deal with input/output without having every part of your code understand the
physical.
Java encapsulates Stream under java.io package. Java
defines two types of streams. They are,
1. Byte Stream : It provides a convenient
means for handling input and output of byte.
2. Character Stream : It provides a
convenient means for handling input and output of characters. Character stream
uses Unicode and therefore can be internationalized.
A stream can be defined as a sequence of
data. There are two kinds of Streams −
·
InPutStream − The InputStream is used to read data from a source.
- OutPutStream − The OutputStream is used for writing data to a destination.
Java provides strong but flexible support
for I/O related to files and networks
Byte Streams
Java byte streams are used to perform
input and output of 8-bit bytes. Though there are many classes related to byte
streams but the most frequently used classes are, FileInputStream and FileOutputStream
Character Streams
Java Byte streams are used to perform
input and output of 8-bit bytes, whereas Java Character streams
are used to perform input and output for 16-bit unicode. Though there are many
classes related to character streams but the most frequently used classes
are, FileReader and FileWriter. Though internally
FileReader uses FileInputStream and FileWriter uses FileOutputStream but here
the major difference is that FileReader reads two bytes at a time and
FileWriter writes two bytes at a time.
InputStream Class
The Java.io.InputStream class is the superclass of all classes representing an input stream of bytes. Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input.
OutputStream Class
The Java.io.OutputStream class
is the superclass of all classes representing an output stream of bytes. An
output stream accepts output bytes and sends them to some sink.Applications
that need to define a subclass of OutputStream must always provide at least a
method that writes one byte of output.
Please Share and Give your reviews.... Thank you
Best OF Luck
Please Share and Give your reviews.... Thank you