Here you can find the source of printBits(byte[] bytes)
public static void printBits(byte[] bytes)
//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()); } }