JBBPBitInputStream extends FilterInputStream implements JBBPCountableBitStream { public boolean[] readBoolArray(final int items) throws IOException { int pos = 0; byte[] buffer; if (items < 0) { buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE]; while (true) { final int read = this.read(buffer, pos, buffer.length - pos); if (read < 0) { break; } pos += read; if (buffer.length == pos) { final byte[] newbuffer = new byte[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } } } else { buffer = new byte[items]; int len = items; while (len > 0) { final int read = this.read(buffer, pos, len); if (read < 0) { throw new EOFException("Have read only " + pos + " bit portions instead of " + items); } pos += read; len -= read; } } final boolean[] result = new boolean[pos]; for (int i = 0; i < pos; i++) { result[i] = buffer[i] != 0; } return result; } JBBPBitInputStream(final InputStream in);  JBBPBitInputStream(final InputStream in, final JBBPBitOrder order); boolean[] readBoolArray(final int items); byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber); byte[] readByteArray(final int items); byte[] readByteArray(final int items, final JBBPByteOrder byteOrder); short[] readShortArray(final int items, final JBBPByteOrder byteOrder); char[] readUShortArray(final int items, final JBBPByteOrder byteOrder); int[] readIntArray(final int items, final JBBPByteOrder byteOrder); float[] readFloatArray(final int items, final JBBPByteOrder byteOrder); long[] readLongArray(final int items, final JBBPByteOrder byteOrder); double[] readDoubleArray(final int items, final JBBPByteOrder byteOrder); int readUnsignedShort(final JBBPByteOrder byteOrder); int readInt(final JBBPByteOrder byteOrder); float readFloat(final JBBPByteOrder byteOrder); long readLong(final JBBPByteOrder byteOrder); double readDouble(final JBBPByteOrder byteOrder); @Override long getCounter(); @Override int getBitBuffer(); @Override int getBufferedBitsNumber(); @Override JBBPBitOrder getBitOrder(); byte readBitField(final JBBPBitNumber numOfBitsToRead); int readBits(final JBBPBitNumber numOfBitsToRead); boolean readBoolean(); int readByte(); @Override synchronized void reset(); @Override synchronized void mark(final int readlimit); void align(final long alignByteNumber); @Override long skip(final long numOfBytes); void alignByte(); boolean hasAvailableData(); @SuppressWarnings("NullableProblems") @Override int read(final byte[] array, final int offset, final int length); @Override void resetCounter(); @SuppressWarnings("NullableProblems") @Override int read(final byte[] array); @Override int read(); String readString(final JBBPByteOrder byteOrder); String[] readStringArray(final int items, final JBBPByteOrder byteOrder);  }
@Test public void testReadBooleanArray_EOF() throws Exception { assertThrows(EOFException.class, () -> asInputStream(1, 2, 3, 4, 5, 6).readBoolArray(256)); }