UnsyncByteArrayInputStream extends InputStream { @Override public long skip(long skip) { if (skip < 0) { return 0; } if ((skip + _index) > _capacity) { skip = _capacity - _index; } _index += skip; return skip; } UnsyncByteArrayInputStream(byte[] buffer);  UnsyncByteArrayInputStream(byte[] buffer, int offset, int length); @Override int available(); @Override void mark(int readAheadLimit); @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() { UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(_BUFFER); long size = _SIZE * 2 / 3; Assert.assertEquals(size, unsyncByteArrayInputStream.skip(size)); Assert.assertEquals( _SIZE - size, unsyncByteArrayInputStream.available()); Assert.assertEquals( _SIZE - size, unsyncByteArrayInputStream.skip(size)); Assert.assertEquals(0, unsyncByteArrayInputStream.available()); Assert.assertEquals(0, unsyncByteArrayInputStream.skip(-1)); }