Here you can find the source of createByteArr(boolean[] booleans)
public static byte[] createByteArr(boolean[] booleans)
//package com.java2s; public class Main { public static byte[] createByteArr(boolean[] booleans) { int length = booleans.length; byte[] bytes = new byte[length / 8 + 1]; for (int i = 0; i < length; i++) { if (!booleans[i]) continue; int word = i >>> 3; bytes[word] |= 1 << (i & 7); }/*from w w w .j av a2s.c o m*/ return bytes; } public static byte[] createByteArr(Boolean[] booleans) { int length = booleans.length; byte[] bytes = new byte[length / 8 + 1]; for (int i = 0; i < length; i++) { if (!booleans[i]) continue; int word = i >>> 3; bytes[word] |= 1 << (i & 7); } return bytes; } }