public static String toStringBinary(final byte[] b, int off, int len) {
    StringBuilder result = new StringBuilder();
    // Just in case we are passed a 'len' that is > buffer length...
    if (off >= b.length) return result.toString();
    if (off + len > b.length) len = b.length - off;
    for (int i = off; i < off + len; ++i) {
      int ch = b[i] & 0xFF;
      if (ch >= ' ' && ch <= '~' && ch != '\\') {
        result.append((char) ch);
      } else {
        result.append("\\x");
        result.append(HEX_CHARS_UPPER[ch / 0x10]);
        result.append(HEX_CHARS_UPPER[ch % 0x10]);
      }
    }
    return result.toString();
  }
Write a printable representation of a byte array. Non-printable characters are hex escaped in
the format \\x%02X, eg: \x00 \x05 etc
@param b   array to write out
@param off offset to start at
@param len length to write
@return string output
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java