Name
DataInputStream
Synopsis
This
class is a type of FilterInputStream that allows
you to read
binary
representations of Java primitive data types in a portable way.
Create a DataInputStream by specifying the
InputStream that is to be filtered in the call to
the constructor. DataInputStream reads only
primitive Java types; use ObjectInputStream to
read object values.
Many of the methods read and return a single Java primitive type, in
binary format, from the stream.
readUnsignedByte( ) and
readUnsignedShort( ) read
unsigned values and
return them as int values, since unsigned
byte
and short types are
not supported in Java. read(
)
reads data into an array of bytes, blocking until at least some data
is available. By contrast, readFully(
)
reads data into an array of
bytes, but blocks until all requested data becomes available.
skipBytes( )
blocks until the specified
number of bytes have been read and discarded. readLine(
)
reads characters from the stream
until it encounters a newline, a carriage return, or a
newline/carriage return pair. The returned string is not terminated
with a newline or carriage return. This method is deprecated as of
Java 1.1; see BufferedReader for an alternative.
readUTF( ) reads a string of Unicode text encoded
in a slightly modified version of the UTF-8 transformation format.
UTF-8 is an ASCII-compatible encoding of Unicode characters that is often used for the transmission and storage of Unicode text. This class uses a modified UTF-8 encoding ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access