protected void readFully(byte[] buf, int off, int len, boolean isPlain) { int origLen = len; if (buf == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > buf.length - off) { throw new IndexOutOfBoundsException(); } while (len > 0) { int nextChunk = Math.min(available(),len); if (nextChunk == 0) { if (!hasNextRecord()) { throw new RecordFormatException("Can't read the remaining "+len+" bytes of the requested "+origLen+" bytes. No further record exists."); } else { nextRecord(); nextChunk = Math.min(available(),len); assert(nextChunk > 0); } } checkRecordPosition(nextChunk); if (isPlain) { _dataInput.readPlain(buf, off, nextChunk); } else { _dataInput.readFully(buf, off, nextChunk); } _currentDataOffset+=nextChunk; off += nextChunk; len -= nextChunk; } }
protected void readFully(byte[] buf, int off, int len, boolean isPlain) { int origLen = len; if (buf == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > buf.length - off) { throw new IndexOutOfBoundsException(); } while (len > 0) { int nextChunk = Math.min(available(),len); if (nextChunk == 0) { if (!hasNextRecord()) { throw new RecordFormatException("Can't read the remaining "+len+" bytes of the requested "+origLen+" bytes. No further record exists."); } else { nextRecord(); nextChunk = Math.min(available(),len); assert(nextChunk > 0); } } checkRecordPosition(nextChunk); if (isPlain) { _dataInput.readPlain(buf, off, nextChunk); } else { _dataInput.readFully(buf, off, nextChunk); } _currentDataOffset+=nextChunk; off += nextChunk; len -= nextChunk; } }