How to handle “EOFException” in java.
DataInputStreams provide methods that can read primitive Java data types from an underlying input stream in a machine-independent way. An application writes data, by using the methods provided by the
OutputStream class, or the
EOFException is thrown, we only have to break from the reading loop and then, close the stream.