Here you can find the source of toBinaryString(byte[] array)
public static String toBinaryString(byte[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static String toBinaryString(byte b) { return String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'); }/*from ww w . j a va2s . c o m*/ public static String toBinaryString(byte[] array) { StringBuffer sb = new StringBuffer(); for (byte b : array) { sb.append(toBinaryString(b)); sb.append(" "); } return sb.toString(); } }