private String pad(int n, byte pad) {
    String res = Integer.toString(n);
    while (res.length() < pad) {
      res = "0" + res;
    }
    return res;
  }
Padding numbers to make comparison of sort order easier in a for loop
@param n   The number to pad.
@param pad The length to pad up to.
@return The padded number as a string.
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java