code: public static int writeString(final DataOutput out, final String s) throws IOException {
  
  		int length = 0;
  
  		if (s == null) {
  			out.writeBoolean(false);
  		} else {
  			out.writeBoolean(true);
  			final ByteBuffer bytes = encode(s);
  			length = bytes.limit();
  			out.writeInt(length);
  			out.write(bytes.array(), 0, length);
  		}
  		return length;
  	}
docs: Write a UTF8 encoded string to out