public static void writeString(String s, DataOutput stream) throws IOException {
    if (s == null) {
      stream.writeInt(-1);
      return;
    }

    final int len = s.length();
    stream.writeInt(len);
    if (len == 0) {
      return;
    }

    int charsWritten = 0;
    final byte[] buff = myBuffer.get();
    while (charsWritten < len) {
      final int bytesWritten = Math.min((len - charsWritten) * 2, buff.length);
      for (int i = 0; i < bytesWritten; i += 2) {
        char aChar = s.charAt(charsWritten++);
        buff[i] = (byte)((aChar >>> 8) & 0xFF);
        buff[i + 1] = (byte)((aChar) & 0xFF);
      }
      stream.write(buff, 0, bytesWritten);
    }
  }
public static void writeString(String s, DataOutput stream)