No. The compressed file is a "binary" file.
To get maximum compression, bytes must be allowed to use all possible binary patterns.
(FileReader
is for text files.)
The DataInputStream
class is the compliment of
the DataOutputStream
class.
Files (and other streams) written with one class are usually read with the other. Here is a list of some of the methods:
Constructor
public DataInputStream(InputStream in) Construct a data input stream.
Methods
public void close() throws IOException public final boolean readBoolean() throws IOException Reads a boolean represented as a 1-byte value. public final byte readByte() throws IOException public final char readChar() throws IOException public final double readDouble() throws IOException public final float readFloat() throws IOException public final int readInt() throws IOException public final long readLong() throws IOException public final short readShort() throws IOException public final int readUnsignedByte() throws IOException
All these methods throw an IOException
if an error occurs.
The DataInputStream
constructor takes a reference to an InputStream
as a parameter.
Usually the parameter will be a reference to a BufferedInputStream
which in turn is connected to a FileInputStream
.
Upon reaching end of file the readxxx methods throw an EOFException
,
a subclass of IOException
.
Reaching end of file is not an error, but throwing an exception is a convenient way of signaling when this happens.
(Thought question: ) Why does readUnsignedByte()
return an int
and not a byte
?