Theory
About Java Input Output:
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 java.io package contains all the classes required for input and output operations.
We can perform file handling in Java by Java I/O API.
This package provides for system input and output through data streams, serialization and the file system. Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
OutputStream vs InputStream:
The explanation of OutputStream and InputStream classes are given below:
OutputStream:
Java application uses an output stream to write data to a destination; it may be a file, an array, peripheral device or socket.
InputStream:
Java application uses an input stream to read data from a source; it may be a file, an array, peripheral device or socket