ByteArrayFileInputStream extends InputStream { @Override public long skip(long skip) throws IOException { if (skip < 0) { return 0; } if (_fileSize < _threshold) { _initData(); if ((skip + _index) > _data.length) { skip = _data.length - _index; } _index += skip; return skip; } _initFileInputStream(); return _fileInputStream.skip(skip); } ByteArrayFileInputStream(File file, int threshold);  ByteArrayFileInputStream(
		File file, int threshold, boolean deleteOnClose); @Override int available(); @Override void close(); File getFile(); @Override void mark(int readLimit); @Override boolean markSupported(); @Override int read(); @Override int read(byte[] bytes); @Override int read(byte[] bytes, int offset, int length); @Override void reset(); @Override long skip(long skip);  }
@Test public void testSkip() throws IOException { ByteArrayFileInputStream byteArrayFileInputStream = new ByteArrayFileInputStream(_testFile, 2048); Assert.assertEquals(0, byteArrayFileInputStream.skip(-1)); int count = 1024 / 17; for (int i = 0; i < count; i++) { Assert.assertEquals(17, byteArrayFileInputStream.skip(17)); } Assert.assertEquals(1024 % 17, byteArrayFileInputStream.skip(17)); Assert.assertEquals(0, byteArrayFileInputStream.skip(17)); byteArrayFileInputStream.close(); byteArrayFileInputStream = new ByteArrayFileInputStream(_testFile, 512); Assert.assertEquals(0, byteArrayFileInputStream.skip(0)); for (int i = 0; i < 1024; i++) { Assert.assertEquals(17, byteArrayFileInputStream.skip(17)); } byteArrayFileInputStream.skip(17); Assert.assertEquals(-1, byteArrayFileInputStream.read()); byteArrayFileInputStream.close(); }