public static String readStringFixedSize(final DataInput in, int size) throws IOException {
    byte[] b = new byte[size];
    in.readFully(b);
    int n = b.length;
    while (n > 0 && b[n - 1] == 0)
      --n;

    return toString(b, 0, n);
  }
Reads a fixed-size field and interprets it as a string padded with zeros.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java