Here you can find the source of toBinString(byte b)
b
as binary String (e.g. "10110111").
public static String toBinString(byte b)
//package com.java2s; //License from project: Mozilla Public License public class Main { /** An byte as a string bit representation. * @return <code>b</code> as binary String (e.g. "10110111"). */ public static String toBinString(byte b) { return toBinString((int) b); }//from ww w .j a v a2 s . c o m /** An int as a string bit representation. * @return <code>i</code> as binary String (e.g. "10110111"). */ public static String toBinString(int i) { boolean bT = ((i & 128) == 128); String s = (bT ? "1" : "0"); bT = ((i & 64) == 64); s += (bT ? "1" : "0"); bT = ((i & 32) == 32); s += (bT ? "1" : "0"); bT = ((i & 16) == 16); s += (bT ? "1" : "0"); bT = ((i & 8) == 8); s += (bT ? "1" : "0"); bT = ((i & 4) == 4); s += (bT ? "1" : "0"); bT = ((i & 2) == 2); s += (bT ? "1" : "0"); bT = ((i & 1) == 1); s += (bT ? "1" : "0"); return s; } }