private void writeBoolList(List<Boolean> boolList) throws IOException {
        byte b = 0;
        int mask = 0x80;
        for (Boolean aBoolList : boolList) {
            if (aBoolList)
                b |= mask;
            mask >>= 1;
            if (mask == 0) {
                writeByte(b);
                mask = 0x80;
                b = 0;
            }
        }
        if (mask != 0x80)
            writeByte(b);
    }