Here you can find the source of bitArray2byte(boolean[] array)
public static byte bitArray2byte(boolean[] array)
//package com.java2s; //License from project: Apache License public class Main { public static byte bitArray2byte(boolean[] array) { if (array == null || array.length != 8) { throw new RuntimeException("Bad bit array"); }//from w w w .j a v a2 s . com byte b = 0; for (int i = 0; i <= 7; i++) { if (array[i]) { // 0000 0001 int nn = (1 << (7 - i)); b += nn; } } return b; } }