/** * Returns a new bytebuffer, of numBytes length and little endian byte order, filled from the * channel. * * @param channel the channel to fill the buffer from * @param numBytes number of bytes to read * @return a new bytebuffer filled from the channel * @throws IOException if there is a problem reading the channel * @throws EOFException if the end of the channel is reached */ private ByteBuffer fillBuffer(ReadableByteChannel channel, int numBytes) throws IOException { ByteBuffer buf = ByteBuffer.allocate(numBytes); if (fill(buf, channel) == -1) { throw new EOFException(Errors.format(ErrorKeys.END_OF_DATA_FILE)); } buf.flip(); buf.order(ByteOrder.LITTLE_ENDIAN); return buf; }