Java Byte Array Dump dumpByteArray(byte[] bytes)

Here you can find the source of dumpByteArray(byte[] bytes)

Description

dump Byte Array

License

BSD License

Declaration

public static void dumpByteArray(byte[] bytes) 

Method Source Code

//package com.java2s;
/*/*from w ww .  jav a2  s  . c  o m*/
 * Copyright (c) 2015, GoMint, BlackyPaw and geNAZt
 *
 * This code is licensed under the BSD license found in the
 * LICENSE file in the root directory of this source tree.
 */

public class Main {
    public static void dumpByteArray(byte[] bytes) {
        int count = 0;
        StringBuilder stringBuilder = new StringBuilder();

        for (byte aByte : bytes) {
            String hex = Integer.toHexString(aByte & 255);
            if (hex.length() == 1) {
                hex = "0" + hex;
            }

            stringBuilder.append(hex).append(" ");
            if (count++ == 16) {
                stringBuilder.append("\n");
                count = 0;
            }
        }

        System.out.println(stringBuilder);
    }
}

Related

  1. dumpArray(byte[] b)
  2. dumpArray(byte[] buffer, boolean breakLines)
  3. dumpByteArray(byte[] ab)
  4. dumpByteArray(byte[] b)
  5. dumpByteArray(byte[] buffer)
  6. dumpByteArrayAsInts(byte[] arr)
  7. dumpBytes(byte bb[])
  8. dumpBytes(byte[] a)
  9. dumpBytes(byte[] b)