@Override public long getFilePointer() throws IOException { ensureOpen(); return filePointer; }
@Override public int read() throws IOException { ensureOpen(); final int result = reader.readByte(filePointer); if (result >= 0) { filePointer++; } return result; }
@Override public void seek(long position) throws IOException { ensureOpen(); if (position < 0) { throw new IOException("Cannot seek to a negative position: " + position); } if (position >= reader.length()) { throw new IOException("Cannot seek past the end of data with length " + reader.length() + ". Seek position was " + position); } filePointer = position; }
@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; }