Here you can find the source of bitsTo8Bytes(boolean[] bits)
public static byte[] bitsTo8Bytes(boolean[] bits)
//package com.java2s; // it under the terms of the GNU Lesser General Public License as published by public class Main { public static byte[] bitsTo8Bytes(boolean[] bits) { byte[] b = new byte[8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { b[i] += (((bits[(8 * i) + j]) ? 1 : 0) << (7 - j)); }/* ww w . ja v a 2s. c o m*/ } return b; } }