Java Bit Print printBits(byte[] bytes)

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

Description

print Bits

License

Open Source License

Declaration

public static void printBits(byte[] bytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static void printBits(byte[] bytes) {
        boolean firstFlag = true;
        StringBuffer logBuffer = new StringBuffer();
        String b = "";
        for (byte i : bytes) {
            b = Integer.toHexString(i & 0xff);
            b = (b.length() == 1 ? ("0" + b) : b);
            if (firstFlag) {
                logBuffer.append("[" + b);
                firstFlag = false;/*  w  w  w .jav a 2 s . co  m*/
            } else {
                logBuffer.append(", " + b);
            }
        }
        logBuffer.append("]");

        System.out.println(logBuffer.toString());
    }
}

Related

  1. printBitBinary(byte[] bytes)
  2. printBitboard(long bitboard)
  3. printBitFormat(int number)
  4. printBitLong(long A)
  5. printBits(int meta)
  6. printBits(int number, int n)
  7. printBits(long val, int bits)
  8. printBits(long value)