Here you can find the source of bytesToBits(byte[] buf)
public static String bytesToBits(byte[] buf)
//package com.java2s; //License from project: Open Source License public class Main { public static String bytesToBits(byte[] buf) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < buf.length; i++) { sb.append(byteToBits(buf[i])); sb.append(","); }//from w ww. ja v a 2 s . co m return sb.toString(); } public static String byteToBits(byte b) { return "" + (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1) + (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1) + (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1) + (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1); } }