public static String toHex(byte[] b, int offset, int length) {
    checkArgument(length <= Integer.MAX_VALUE / 2);
    int numChars = length * 2;
    char[] ch = new char[numChars];
    for (int i = 0; i < numChars; i += 2) {
      byte d = b[offset + i / 2];
      ch[i] = HEX_CHARS[(d >> 4) & 0x0F];
      ch[i + 1] = HEX_CHARS[d & 0x0F];
    }
    return new String(ch);
  }
Convert a byte range into a hex string
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java