Here you can find the source of toBinary(byte b)
public static String toBinary(byte b)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { public static final String BIN_PREFIX = "0b"; public static String toBinary(byte b) { return toBinary(b, BIN_PREFIX); }/*w w w.jav a 2 s .c o m*/ public static String toBinary(byte b, String prefix) { String result = ""; for (int i = 0; i < 8; i++) { result += (b >>> (7 - i)) & (0x01); } return result; } public static String toBinary(short s, String prefix) { String result = toBinary((byte) (s >>> 8), ""); result += toBinary((byte) (s), ""); return prefix + result; } }