public static void writeStringFixedSize(final DataOutput out, String s, int size)
    throws IOException {
    byte[] b = toBytes(s);
    if (b.length > size) {
      throw new IOException("Trying to write " + b.length + " bytes (" + toStringBinary(b)
        + ") into a field of length " + size);
    }

    out.writeBytes(s);
    for (int i = 0; i < size - s.length(); ++i)
      out.writeByte(0);
  }
Writes a string as a fixed-size field, padded with zeros.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java