List of utility methods to do ByteBuffer to Hex
String | toHex(ByteBuffer data) Convert data from given ByteBuffer to hex StringBuilder result = new StringBuilder(); int counter = 0; int b; while (data.hasRemaining()) { if (counter % 16 == 0) result.append(String.format("%04X: ", counter)); b = data.get() & 0xff; result.append(String.format("%02X ", b)); ... |
String | toHexStr(final ByteBuffer data) Convert the bytes to a hex string. final StringBuilder sysex = new StringBuilder(); while (data.position() < data.limit()) sysex.append(toHexStr(Byte.toUnsignedInt(data.get()))).append(' '); return sysex.toString(); |
String | toHexStream(ByteBuffer data) Convert data from given ByteBuffer to hex StringBuilder result = new StringBuilder(); int counter = 0; int b; while (data.hasRemaining()) { b = data.get() & 0xff; result.append(String.format("%02X ", b)); counter++; if (counter % 16 == 0) { ... |
String | toHexString(ByteBuffer bb) to Hex String ByteBuffer buffer = bb.duplicate(); StringBuilder hex = new StringBuilder(); while (buffer.hasRemaining()) { byte b = buffer.get(); hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))); return hex.toString(); |
String | toHexString(ByteBuffer bb) to Hex String return appendHex(new StringBuilder(), bb).toString(); |
String | toHexString(ByteBuffer bb, boolean withSpaces) to Hex String byte[] data = new byte[bb.remaining()]; int position = bb.position(); bb.get(data); bb.position(position); return toHexString(data, withSpaces); |
String | toHexString(ByteBuffer buffer) to Hex String final StringBuilder r = new StringBuilder(buffer.remaining() * 2); while (buffer.hasRemaining()) { final byte b = buffer.get(); r.append(HEX_CODE[(b >> 4) & 0xF]); r.append(HEX_CODE[(b & 0xF)]); return r.toString(); |
String | toHexString(ByteBuffer buffer) to Hex String StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); for (int i = buffer.position(); i < buffer.limit(); i++) { byte b = buffer.get(i); pw.format("%02X ", b); return sw.toString(); |
String | toHexString(ByteBuffer buffer, int size) Convert a byte buffer to a hexadecimal string for display return toHexString(buffer, 0, size);
|
String | toHexString(ByteBuffer byteBuffer) Encodes a byte buffer into hex (no spaces) string from the current position. if (byteBuffer == null) { return null; StringBuilder sb = new StringBuilder(); int pos = byteBuffer.position(); while (byteBuffer.hasRemaining()) { String hex = Integer.toHexString(0xFF & byteBuffer.get()); if (hex.length() == 1) { ... |