Java Utililty Methods ByteBuffer Dump

List of utility methods to do ByteBuffer Dump

Description

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

Method

Stringbbdump(ByteBuffer sbb)
bbdump
ByteBuffer bb = sbb.asReadOnlyBuffer();
byte[] bytes = new byte[bb.capacity()];
bb.get(bytes);
bb.rewind();
return Arrays.toString(bytes);
Stringdump(ByteBuffer bb)
dump
return dump(bb, Integer.MAX_VALUE);
Stringdump(ByteBuffer buff, int size, boolean asBits)
dump
return dump(buff.array(), size, asBits);
voiddump(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)
...
voiddump(ByteBuffer buffer)
dump
ByteBuffer dup = buffer.duplicate();
byte[] bs = new byte[dup.position()];
dup.flip();
dup.get(bs);
System.out.println(new String(bs));
Stringdump(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();
voiddump(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);
StringdumpAsHex(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) {
...
booleandumpBoolean(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 {
...
StringdumpBytes(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 {
...