Here you can find the source of byteToBits(byte b)
private static String byteToBits(byte b)
//package com.java2s; //License from project: Open Source License public class Main { private static String byteToBits(byte b) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < 8; i++) buf.append((int) (b >> (8 - (i + 1)) & 0x0001)); return buf.toString(); }//from w w w . jav a 2 s.c o m }