RandomAccessFileInputStream extends InputStream { @Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } int available = available(); if (available <= 0) { return 0; } int skipAmount = (int) Math.min(available, n); raf.seek(raf.getFilePointer() + skipAmount); return skipAmount; } 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 testSkip() throws IOException { Assert.assertEquals(0, stream.skip(-1)); Assert.assertEquals(0, stream.skip(0)); Assert.assertEquals(5, stream.skip(5)); Assert.assertEquals(5, stream.read()); Assert.assertEquals(testData.length - 5 - 1, stream.skip(testData.length)); Assert.assertEquals(0, stream.skip(17)); }