DataInputStream.readUTF

DataInputStream.readUTF

Class Overview | Class Members | This Package | All Packages

Syntax 1
public final String readUTF() throws IOException
Returns
a Unicode string.
Description
Reads in a string that has been encoded using a modified UTF-8 format from this data input stream. This method calls readUTF(this). See readUTF(java.io.DataInput) for a more complete description of the format.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Exceptions
EOFException if this input stream reaches the end before reading all the bytes.
Exceptions
IOException if an I/O error occurs.
See Also
readUTF



Syntax 2
public static final String readUTF( DataInput in ) throws IOException
Parameters
in
a data input stream.
Returns
a Unicode string.
Description
Reads in a string from the specified data input stream. The string has been encoded using a modified UTF-8 format.

The first two bytes are read as if by readUnsignedShort. This value gives the number of following bytes that are in the encoded string, not the length of the resulting string. The following bytes are then interpreted as bytes encoding characters in the UTF-8 format and are converted into characters.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Exceptions
EOFException if the input stream reaches the end before all the bytes.
Exceptions
IOException if an I/O error occurs.
Exceptions
UTFDataFormatException if the bytes do not represent a valid UTF-8 encoding of a Unicode string.
See Also
readUnsignedShort