code: public static void append(StringBuilder buf, byte b, int base) {
          int bi = 0xff & b;
          int c = '0' + (bi / base) % base;
          if (c > '9')
              c = 'a' + (c - '0' - 10);
          buf.append((char) c);
          c = '0' + bi % base;
          if (c > '9')
              c = 'a' + (c - '0' - 10);
          buf.append((char) c);
      }
docs: append hex digit
  
  @param buf  the buffer to append to
  @param b    the byte to append
  @param base the base of the hex output (almost always 16).