Here you can find the source of byteToBits(byte b)
public static String byteToBits(byte b)
//package com.java2s; //PduUtils is distributed under the terms of the Apache License version 2.0 public class Main { public static String byteToBits(byte b) { String bits = Integer.toBinaryString(b & 0xFF); while (bits.length() < 8) { bits = "0" + bits; }// w ww.j a v a2 s . co m return bits; } }