int bitsToByte(List<bool> bits) { int value = 0; for (int i = 0; i < bits.length; i++) { if (bits[i]) value |= (1 << i); } return value; }