code: public int[] readIntArray(final int items, final JBBPByteOrder byteOrder) throws IOException {
      int pos = 0;
      if (items < 0) {
        int[] buffer = new int[INITIAL_ARRAY_BUFFER_SIZE];
        // till end
        while (hasAvailableData()) {
          final int next = readInt(byteOrder);
          if (buffer.length == pos) {
            final int[] newbuffer = new int[buffer.length << 1];
            System.arraycopy(buffer, 0, newbuffer, 0, buffer.length);
            buffer = newbuffer;
          }
          buffer[pos++] = next;
        }
        if (buffer.length == pos) {
          return buffer;
        }
        final int[] result = new int[pos];
        System.arraycopy(buffer, 0, result, 0, pos);
        return result;
      } else {
        // number
        final int[] buffer = new int[items];
        for (int i = 0; i < items; i++) {
          buffer[i] = readInt(byteOrder);
        }
        return buffer;
      }
    }
docs: Read number of integer items from the input stream.
  
  @param items     number of items to be read from the input stream, if less than
  zero then all stream till the end will be read
  @param byteOrder the order of bytes to be used to decode values
  @return read items as an integer array
  @throws IOException it will be thrown for any transport problem during the
  operation
  @see JBBPByteOrder#BIG_ENDIAN
  @see JBBPByteOrder#LITTLE_ENDIAN