@Override public int read(byte[] buffer, int off, int count) throws IOException { final int bytesCopied = ArchiveFileUtils.copyToBuffer(reader, position, buffer, off, count); position += bytesCopied; return bytesCopied; }
@Override public int read(final ByteBuffer dst) throws IOException { if (isOpen) { final int bytesCopied = ArchiveFileUtils.copyToBuffer(reader, position, dst); position += bytesCopied; return bytesCopied; } return -1; }
@Override public void read(final long devOffset, final ByteBuffer dest) throws IOException { ensureOpen(); final int bytesRequested = dest.remaining(); if (devOffset + bytesRequested > reader.length()) { throw new EOFException("Reading past end of device"); } ArchiveFileUtils.copyToBuffer(reader, devOffset, dest); }
@Override public int read(byte[] bytes, int offset, int length) throws IOException { ensureOpen(); if ((offset | length) < 0) { throw new IndexOutOfBoundsException("Offset or length cannot be negative: {" + offset + "," + length + "}"); } if (filePointer >= length() || length == 0) { return -1; } final int bytesCopied = ArchiveFileUtils.copyToBuffer(reader, filePointer, bytes, offset, length); filePointer += bytesCopied; return bytesCopied; }