RandomAccessFile.readUTF

RandomAccessFile.readUTF

Class Overview | Class Members | This Package | All Packages

Syntax
public final String readUTF() throws IOException
Returns
a Unicode string.
Description
Reads in a string from this file. 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 this file reaches the end before reading all the bytes.
Exceptions
IOException if an I/O error occurs.
Exceptions
UTFDataFormatException if the bytes do not represent valid UTF-8 encoding of a Unicode string.
See Also
readUnsignedShort