public override string ReadString()
{
short length = ReadInt16();
if (length < 0) {
throw new NbtFormatException("Negative string length given!");
}
if (length < stringConversionBuffer.Length) {
int stringBytesRead = 0;
while (stringBytesRead < length) {
int bytesReadThisTime = BaseStream.Read(stringConversionBuffer, stringBytesRead, length);
if (bytesReadThisTime == 0) {
throw new EndOfStreamException();
}
stringBytesRead += bytesReadThisTime;
}
return Encoding.UTF8.GetString(stringConversionBuffer, 0, length);
} else {
byte[] stringData = ReadBytes(length);
if (stringData.Length < length) {
throw new EndOfStreamException();
}
return Encoding.UTF8.GetString(stringData);
}
}