Here you can find the source of bytesToBits(byte[] b)
public static String bytesToBits(byte[] b)
//package com.java2s; //PduUtils is distributed under the terms of the Apache License version 2.0 public class Main { public static String bytesToBits(byte[] b) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < b.length; i++) { String bits = Integer.toBinaryString(b[i] & 0xFF); while (bits.length() < 8) { bits = "0" + bits; }/*from w w w .j a va 2 s. c o m*/ if (i > 0) { sb.append(" "); } sb.append(bits); } return sb.toString(); } }