List of utility methods to do ByteBuffer Dump
String | bbdump(ByteBuffer sbb) bbdump ByteBuffer bb = sbb.asReadOnlyBuffer(); byte[] bytes = new byte[bb.capacity()]; bb.get(bytes); bb.rewind(); return Arrays.toString(bytes); |
String | dump(ByteBuffer bb) dump return dump(bb, Integer.MAX_VALUE);
|
String | dump(ByteBuffer buff, int size, boolean asBits) dump return dump(buff.array(), size, asBits);
|
void | dump(ByteBuffer buffer) dump System.out.println(); int mark = buffer.position(); int ii = 0; while (buffer.hasRemaining()) { if ((ii & 15) == 0) System.out.printf("%04X: ", ii); System.out.printf("%02X ", buffer.get()); if ((ii & 15) == 15) ... |
void | dump(ByteBuffer buffer) dump ByteBuffer dup = buffer.duplicate(); byte[] bs = new byte[dup.position()]; dup.flip(); dup.get(bs); System.out.println(new String(bs)); |
String | dump(ByteBuffer buffer, int pos, int limit) dump int oldpos = buffer.position(); int oldlimit = buffer.limit(); buffer.limit(limit).position(pos); StringBuilder builder = new StringBuilder("["); for (int idx = buffer.position(); idx < buffer.limit(); ++idx) { builder.append(buffer.get(idx)); builder.append(','); builder.append(']'); buffer.limit(oldlimit).position(oldpos); return builder.toString(); |
void | dump(ByteBuffer buffer, OutputStream stream) dump int size = buffer.limit() - buffer.position(); byte[] bytes = new byte[size]; System.arraycopy(buffer.array(), buffer.position(), bytes, 0, size); dump(bytes, 0, stream, 0); |
String | dumpAsHex(byte[] byteBuffer, int length) Dumps the given bytes to STDOUT as a hex dump (up to length bytes). StringBuilder outputBuilder = new StringBuilder(length * 4); int p = 0; int rows = length / 8; for (int i = 0; (i < rows) && (p < length); i++) { int ptemp = p; for (int j = 0; j < 8; j++) { String hexVal = Integer.toHexString(byteBuffer[ptemp] & 0xff); if (hexVal.length() == 1) { ... |
boolean | dumpBoolean(ByteBuffer itemBuffer, StringBuilder sb, String tag) dump Boolean sb.append("<"); sb.append(tag); sb.append(" exists = \""); boolean exists = readBoolean(itemBuffer); sb.append(exists); if (exists) { sb.append("\">"); } else { ... |
String | dumpBytes(ByteBuffer bbuf) dump Bytes StringBuilder str = new StringBuilder(); int len = bbuf.remaining(); ByteBuffer b = bbuf.slice(); for (int i = 0; i < len; i++) { int _b = ((int) b.get()) & 0xff; if (_b >= 0x20 && _b <= 0x7e) { str.append((char) _b); } else { ... |