RandomAccessFileInputStream extends InputStream { public long getPosition() throws IOException { return raf.getFilePointer(); } RandomAccessFileInputStream(File file);  RandomAccessFileInputStream(File file, long rangeOffset, long rangeLength); void setRange(long rangeOffset, long rangeLength); @Override int available(); long getPosition(); @Override void close(); @Override int read(); @Override int read(byte[] b, int off, int len); @Override int read(byte[] b); @Override long skip(long n); @Override boolean markSupported(); @Override void mark(int readlimit); @Override void reset(); long length();  }
@Test public void testGetPosition() throws IOException { stream = new RandomAccessFileInputStream(tempFile, 5, 2); Assert.assertEquals(5, stream.getPosition()); stream.read(); Assert.assertEquals(6, stream.getPosition()); stream.setRange(0, 1); Assert.assertEquals(0, stream.getPosition()); }