Java I/O
Java I/O (Input and Output) is used to process the input and produce the output.
Java uses the concept of a stream to make I/O operation fast. The [Link]
package contains all the classes required for input and output operations.
We can perform file handling in Java by Java I/O API.
Stream
A stream is a sequence of data. In Java, a stream is composed of bytes. It's
called a stream because it is like a stream of water that continues to flow.
In Java, 3 streams are created for us automatically. All these streams are
attached with the console.
1) [Link]: standard output stream
2) [Link]: standard input stream
3) [Link]: standard error stream
An input stream is used to read data from the source. And, an output stream is
used to write data to the destination.
Types of Streams
Depending upon the data a stream holds, it can be classified into:
● Byte Stream
● Character Stream
Byte Stream
Byte stream is used to read and write a single byte (8 bits) of data.
All byte stream classes are derived from base abstract classes called
InputStream and OutputStream.
Character Stream
Character stream is used to read and write a single character of data.
All the character stream classes are derived from base abstract classes Reader
and Writer.