Here you can find the source of bitString(byte b)
public static String bitString(byte b)
//package com.java2s; //License from project: Apache License public class Main { public static String bitString(byte b) { StringBuilder buff = new StringBuilder(); boolean[] array = byteToBitArray(b); for (int i = 0; i < array.length; i++) { buff.append(array[i] ? 1 : 0); }/*w w w .ja v a2 s . co m*/ return buff.toString(); } public static boolean[] byteToBitArray(byte b) { boolean[] buff = new boolean[8]; int index = 0; for (int i = 7; i >= 0; i--) { buff[index++] = ((b >>> i) & 1) == 1; } return buff; } }