readUTF8 method

String readUTF8()

Reads a string encoded in UTF8. This method first reads a 2 byte unsigned integer decoded with the current endian setting, giving the number of UTF8 bytes to read. It then reads those bytes, and converts them to a string using Dart's UTF8 conversion. This may be incompatible with java.io.DataOutputStream for a string that contains nulls.

Throws EOFException if EOF is reached before the needed bytes are read.

Implementation

String readUTF8() {
  final len = readUnsignedShort();
  final bytes = readBytesImmutable(len);
  return _utf8Decoder.convert(bytes);
}