Java Dump Byte Array dumpBuffer(final PrintStream out, final String label, final byte[] b)

Here you can find the source of dumpBuffer(final PrintStream out, final String label, final byte[] b)

Description

dump Buffer

License

Open Source License

Declaration

public static void dumpBuffer(final PrintStream out, final String label, final byte[] b) 

Method Source Code

//package com.java2s;

import java.io.PrintStream;

public class Main {
    public static void dumpBuffer(final PrintStream out, final String label, final byte[] b) {
        dumpBuffer(out, label, b, 0, b.length);
    }// w  w w .  j a  v  a  2s  .  c  o m

    public static void dumpBuffer(final PrintStream out, final byte[] b) {
        dumpBuffer(out, null, b, 0, b.length);
    }

    public static void dumpBuffer(final PrintStream out, final byte[] b, final int offset, final int len) {
        dumpBuffer(out, null, b, offset, len);
    }

    public static void dumpBuffer(final PrintStream out, final String label, final byte[] b, final int offset,
            final int len) {
        if (label != null)
            out.format("-- DUMP -- %s: \n", label);
        out.format("{\n    ", label);
        for (int j = 0; j < len; ++j) {
            out.format("%02X", b[j + offset]);
            if (j + 1 < len) {
                if ((j + 1) % 8 == 0)
                    out.print("\n    ");
                else
                    out.print(' ');
            }
        }
        out.format("\n}\n");
    }
}

Related

  1. dump(byte[] buffer, int start, int size, PrintStream out)
  2. dump(byte[] data, OutputStream out, boolean closeOutput)
  3. dump(final byte[] b, final PrintStream out)
  4. dump(PrintStream printer, byte[] buffer, int offset, int count)
  5. dumpByteArray(byte[] byteArray)
  6. dumpByteArray(byte[] bytes)
  7. dumpBytes(PrintStream printStream, byte bytes[])
  8. dumpBytesAsString(ByteArrayOutputStream baos)