code: public static void writeString(DataOutput out, String s) throws IOException {
      if (s != null) {
        Text text = new Text(s);
        byte[] buffer = text.getBytes();
        int len = text.getLength();
        writeVInt(out, len);
        out.write(buffer, 0, len);
      } else {
        writeVInt(out, -1);
      }
    }
docs: Write a String as a VInt n, followed by n Bytes as in Text format.
  
  @param out
  @param s
  @throws IOException