Java tutorial
//package com.java2s; public class Main { public static String byte2bits(byte b) { int z = b; z |= 256; String str = Integer.toBinaryString(z); int len = str.length(); return str.substring(len - 8, len); } }