Java Array Dump dumpOctets(byte[] data)

Here you can find the source of dumpOctets(byte[] data)

Description

dump Octets

License

Open Source License

Declaration

public static void dumpOctets(byte[] data) 

Method Source Code

//package com.java2s;
// This copy of Ice is licensed to you under the terms described in the

public class Main {
    public static void dumpOctets(byte[] data) {
        final int inc = 8;

        for (int i = 0; i < data.length; i += inc) {
            for (int j = i; j - i < inc; j++) {
                if (j < data.length) {
                    int n = data[j];
                    if (n < 0) {
                        n += 256;//  w  ww  .j  av  a  2  s  .co m
                    }
                    String s;
                    if (n < 10) {
                        s = "  " + n;
                    } else if (n < 100) {
                        s = " " + n;
                    } else {
                        s = "" + n;
                    }
                    System.out.print(s + " ");
                } else {
                    System.out.print("    ");
                }
            }

            System.out.print('"');

            for (int j = i; j < data.length && j - i < inc; j++) {
                if (data[j] >= (byte) 32 && data[j] < (byte) 127) {
                    System.out.print((char) data[j]);
                } else {
                    System.out.print('.');
                }
            }

            System.out.println('"');
        }
    }
}

Related

  1. dumpInt(String name, int[] src)
  2. dumpIntArray(int[] A, int n)
  3. dumpIntArray(int[] data, String label)
  4. dumpMatrix(byte[] matrix, int numDataUnits, int numAllUnits)
  5. dumpMessage(byte b[])
  6. dumpPosition(long[] position)
  7. dumpStackTrace(StackTraceElement[] elements)
  8. dumpString(byte[] b)
  9. dumpString(byte[] b)