Convert buffer to a Hex String.

@param buffer the buffer to generate a hex byte summary from
@return A hex string
330227
public static String toHexString(ByteBuffer buffer) {
        if (buffer == null)
            return "null";
        return TypeUtils.toHexString(toArray(buffer));
    }
155580
private static String getLongString(ByteBuffer buffer)
    {
        long len = getUnsignedInt(buffer);
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < len; i++)
        {
            builder.append((char)(buffer.get() & 0xff));
        }
        String s = builder.toString();
        return s;
    }
1234342
public static String byteBufferToString (final ByteBuffer buffer) {

        if (buffer == null) return "null";

        final int numberOfBytes = buffer.limit();

        final StringBuilder sb = new StringBuilder();
        buffer.position(0);
        int value;
        for (int i = 1; i <= numberOfBytes; ++i) {
            sb.append("0x");
            value = 255 & buffer.get();
            if (value < 16) sb.append("0");
            sb.append(Integer.toHexString(value));
            if (i % BYTES_PER_LINE == 0)
                sb.append("\n");
            else
                sb.append("   ");
        }

        return sb.toString();
    }
175710
public static String toHexSummary(ByteBuffer buffer) {
        if (buffer == null)
            return "null";
        StringBuilder buf = new StringBuilder();

        buf.append("b[").append(buffer.remaining()).append("]=");
        for (int i = buffer.position(); i < buffer.limit(); i++) {
            TypeUtils.toHex(buffer.get(i), buf);
            if (i == buffer.position() + 24 && buffer.limit() > buffer.position() + 32) {
                buf.append("...");
                i = buffer.limit() - 8;
            }
        }
        return buf.toString();
    }
327279
public final static String toHex(byte [] b) {
	char[] buf = new char[b.length * 2];
	int i, j, k;

	i = j = 0;
	for (; i < b.length; i++) {
	    k = b[i];
	    buf[j++] = hex[(k >>> 4) & 0x0F];
	    buf[j++] = hex[ k & 0x0F];
	}
	return new String(buf);
    }
823920
public static String bytesToHex(byte[] raw) {
    if (raw == null) {
      return null;
    }
    final StringBuilder hex = new StringBuilder(2 * raw.length);
    for (final byte b : raw) {
      hex.append(Character.forDigit((b & 0xF0) >> 4, 16))
          .append(Character.forDigit((b & 0x0F), 16));
    }
    return hex.toString();
  }
658251
private static String byte2hex(byte[] bytes) {
        char[] hexChars =
                {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
                        'c', 'd', 'e', 'f'};

        StringBuffer sb = new StringBuffer();
        for (byte b : bytes) {
            sb.append(hexChars[b >> 4 & 0xf]);
            sb.append(hexChars[b & 0xf]);
        }

        return new String(sb);
    }
204996
private static String generateString(byte[] bytes) {

    StringBuffer sb = new StringBuffer();

    for (byte b : bytes) {

      int v = b & 0xFF;

      sb.append((char) HEX.charAt(v >> 4));
      sb.append((char) HEX.charAt(v & 0x0f));
    }

    return sb.toString();
  }
710403
public static String byteArrayToHexString(byte[] bytes) {
    char[] hexChars = new char[bytes.length * 2];
    for (int j = 0; j < bytes.length; j++) {
      int v = bytes[j] & 0xFF;
      hexChars[j * 2] = HEX_SYMBOLS[v >>> 4];
      hexChars[j * 2 + 1] = HEX_SYMBOLS[v & 0x0F];
    }
    return new String(hexChars);
  }
248441
public static String readString(ByteBuffer byteBuffer) {

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int read;
        while ((read = byteBuffer.get()) != 0) {
            out.write(read);
        }
        return Utf8.convert(out.toByteArray());
    }
201393
private static String bytesToHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            int v = bytes[i] & 0xFF;
            hexChars[i * 2] = hexArray[v >>> 4];
            hexChars[i * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
1197478
String getHexString() {
        final ByteBuffer bytes = getBytes();
        final byte[] array = new byte[bytes.remaining()];
        bytes.get(array);
        final StringBuilder sb = new StringBuilder();
        for (byte b : array) {
            sb.append(String.format("%02x ", b));
        }
        return sb.toString();
    }
127348
private static String byteArrayToHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * 2);
        for (byte element : bytes) {
            int v = element & 0xff;
            if (v < 16) {
                sb.append('0');
            }
            sb.append(Integer.toHexString(v));
        }
        return sb.toString();
    }
638693
public static String toHex(byte[] b) {
        char[] buf = new char[b.length * 2];
        int j = 0;
        int k;

        for (byte aB : b) {
            k = aB;
            buf[j++] = HEX[(k >>> 4) & 0x0F];
            buf[j++] = HEX[k & 0x0F];
        }
        return new String(buf);
    }
875962
static String toHex(byte[] data) {

        StringBuffer sb = new StringBuffer(data.length*2);

        for (int i=0; i<data.length; i++) {
            sb.append(hexc[(data[i] >>4) & 0x0f]);
            sb.append(hexc[data[i] & 0x0f]);
        }
        return sb.toString();
    }
993988
public static String encodeHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEX_CHARS[v >>> 4];
            hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F];
        }
        return new String(hexChars);
    }
105525
public static String toHex(byte b) {
      StringBuilder sb = new StringBuilder();
      appendByteAsHex(sb, b);
      return sb.toString();
   }