Java Utililty Methods ByteBuffer to Hex

List of utility methods to do ByteBuffer to Hex

Description

The list of methods to do ByteBuffer to Hex are organized into topic(s).

Method

StringtoHexString(ByteBuffer byteBuffer)
to Hex String
byteBuffer.rewind();
return toHexString(byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(),
        byteBuffer.remaining(), 4);
StringtoHexString(final ByteBuffer buffer)
Creates an hexadecimal string representation of the given ByteBuffer.
ByteBuffer buf = buffer.asReadOnlyBuffer();
buf.rewind();
char[] hexChars = new char[buffer.limit() * 2];
for (int j = 0; j < buf.limit(); j++) {
    int v = buf.get() & 0xFF;
    hexChars[j * 2] = HEX_CHAR_ARRAY[v >>> 4];
    hexChars[j * 2 + 1] = HEX_CHAR_ARRAY[v & 0x0F];
return new String(hexChars);
StringtoHexValue(ByteBuffer buffer)
to Hex Value
StringBuffer result = new StringBuffer(buffer.remaining() * 2);
while (buffer.hasRemaining()) {
    String value = Integer.toHexString(buffer.get() & 0xff);
    if (value.length() == 1)
        result.append("0"); 
    result.append(value);
return result.toString();
...