Java Utililty Methods Array Dump

List of utility methods to do Array Dump

Description

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

Method

StringdumpArray(T[] ts)
dump Array
if (ts == null) {
    return "NULL ARRAY";
StringBuilder sb = new StringBuilder();
int num = 0;
for (T t : ts) {
    sb.append(t);
    if (num != ts.length - 1) {
...
StringdumpArrayHex(byte b[])
dump Array Hex
return dumpArrayHex(b, 0, b.length);
voiddumpAsciiChars(byte[] b, int blen)
Print a dump hex of the byte of array
int lineBytes;
System.out.print("            ");
for (lineBytes = 0; lineBytes < blen; lineBytes++) {
    if ((b[lineBytes] >= 32) && (b[lineBytes] <= 126)) {
        System.out.print((char) b[lineBytes]);
    } else {
        System.out.print(".");
System.out.println();
StringdumpAsHex(byte[] byteBuffer, int length)
Dumps the given bytes to STDOUT as a hex dump (up to length bytes).
StringBuffer outputBuf = new StringBuffer(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) {
...
StringdumpAsHex(byte[] src, int length)
dump As Hex
StringBuilder out = 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(src[ptemp] & 0xff);
        if (hexVal.length() == 1)
...
voiddumpCharCharArray(String msg, char[][] o)
dump Char Char Array
dump("DUMPING char[][]:" + msg); 
for (int i = 0; i < o.length; i++) {
    dump(new String(o[i]));
StringdumpData(byte data[])
Dump an array of bytes
String ret = "";
for (int i = 0; i < data.length; i++) {
    ret += String.format("%2x", data[i]).replace(' ', '0') + " ";
return ret;
byte[]dumpFirst1024Byte(byte[] data)
Dump the first 1024 byte of an byte-array.
byte[] ret = new byte[0];
if (data.length >= 1024) {
    ret = new byte[data.length - 1024];
    System.arraycopy(data, 1024, ret, 0, data.length - 1024);
return ret;
voiddumpGroups(String title, int[][] allGroups)
Dumps the given groups to the console.
System.out.print(title + " {");
for (int group = 0; group < allGroups.length; group++) {
    int[] groupIndices = allGroups[group];
    System.out.print(" {");
    for (int i = 0; i < groupIndices.length; i++) {
        System.out.print(groupIndices[i]);
        if (i < groupIndices.length - 1) {
            System.out.print(", ");
...
StringdumpHex(byte[] data, int offset, int length)
Returns the RAW bytes as hexadecimal string.
char[] hex = new char[2 * length];
for (int i = 0; i < length; ++i) {
    final int b = data[offset + i] & 0xFF;
    hex[2 * i + 0] = HEX[b >>> 4];
    hex[2 * i + 1] = HEX[b & 0x0F];
return new String(hex);