Here you can find the source of toBinary(byte b)
public static String toBinary(byte b)
//package com.java2s; //License from project: Open Source License public class Main { /** Most significant bits mask for binary operations */ public static final int MOST_SIGNIFICANT_MASK = 0xFF; /** Just for debugging and testing purposes */ public static String toBinary(byte b) { return String.format("%8s", Integer.toBinaryString(b & MOST_SIGNIFICANT_MASK)).replace( ' ', '0'); }/*from w w w. j a v a 2 s . c o m*/ }