public static String readString(DataInput stream) throws IOException {
    final int length = stream.readInt();
    if (length == -1) {
      return null;
    }

    if (length == 0) {
      return "";
    }

    char[] chars = new char[length];
    int charsRead = 0;

    final byte[] buff = myBuffer.get();
    while (charsRead < length) {
      final int bytesRead = Math.min((length - charsRead) * 2, buff.length);
      stream.readFully(buff, 0, bytesRead);
      for (int i = 0 ; i < bytesRead; i += 2) {
        chars[charsRead++] = (char)((buff[i] << 8) + (buff[i + 1] & 0xFF));
      }
    }

    return new String(chars);
  }
public static String readString(DataInput stream)