List of utility methods to do ByteBuffer to Hex
String | toHexString(ByteBuffer byteBuffer) to Hex String byteBuffer.rewind();
return toHexString(byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(),
byteBuffer.remaining(), 4);
|
String | toHexString(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); |
String | toHexValue(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(); ... |