code: public boolean[] readBoolArray(final int items) throws IOException {
      int pos = 0;
      byte[] buffer;
      if (items < 0) {
        buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE];
        // till end
        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 {
        // number
        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;
    }
docs: Read array of boolean values.
  
  @param items number of items to be read, if less than zero then read whole
  stream till the end
  @return read values as boolean array
  @throws IOException it will be thrown for transport error