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

voiddump(double[][] a)
dump
for (int i = 0; i < a.length; i++)
    dump(a[i]);
System.out.println();
StringBuilderdump(final StringBuilder buffer, final byte[] data, final int offset, final int length)
dump
for (int i = 0; i < length; i++) {
    if (i % 16 == 0)
        buffer.append("\n");
    buffer.append(String.format("%02x "));
return buffer;
voiddump(String name, byte[] in)
dump
int x = 0, bar_length = ((64 - name.length()) / 2);
String bar_left, bar = "";
for (int y = 0; y < bar_length; ++y)
    bar += "-";
bar_left = bar;
if (bar_length % 64 != 0)
    bar_left += "-";
System.out.print("+" + bar_left + name + bar + "+\n|");
...
voiddump(String t, String[] arr)
dump
System.out.println("--------" + t + "-------------");
for (int i = 0; i < arr.length; i++) {
    System.out.println("#" + i + "='" + arr[i] + "'");
voiddump(T[] from, T[] to)
Replaces all the data in to with from without making modifications to the array being dumped.
if (from.length != to.length)
    throw new IllegalArgumentException("Arrays must be equal in size!");
for (int i = 0; i < from.length; i++)
    to[i] = from[i];
Stringdump_octets(byte[] oct)
dumoctets
StringBuilder sb = new StringBuilder();
dump_octets(oct, 0, oct.length, sb);
return sb.toString();
voiddump_strarr(String[] arr, String doc)
dumstrarr
System.out.println(doc);
for (int i = 0; i < arr.length; i++) {
    System.out.println("(" + i + ") " + arr[i]);
voiddumpArray(final float[] array, final int maxElemsPerLine)
Dumps the contents of the given array to stdout.
if (array == null) {
    System.out.println((String) null);
    return;
int line = 0;
System.out.print("[ ");
for (int i = 0; i < array.length; i++) {
    if ((i > 0) && ((i % maxElemsPerLine) == 0)) {
...
StringdumpArray(String msg, float[][] A, int x1, int x2, int y1, int y2)
dump Array
String s = "dumpArray: " + msg + "\n";
for (int x = x1; x <= x2; x++)
    s += "\t*" + x + "*";
for (int y = y2; y >= y1; y--) {
    s += "\n*" + y + "*";
    for (int x = x1; x <= x2; x++)
        s += "\t" + (x < A.length && y < A[x].length ? A[x][y] : Float.NaN);
return s;
voiddumpArray(String msg, Object[] refs)
dump Array
System.out.println("DUMPING array: " + msg); 
if (refs == null) {
    System.out.println("null"); 
    return;
for (int i = 0; i < refs.length; i++)
    System.out.println(refs[i].toString());