@Test public void testSkip() throws Exception { final LimitedInputStream lis = new LimitedInputStream(bais, 4); assertEquals(3, lis.read(buffer3)); assertEquals(1, lis.skip(data.length)); lis.reset(); assertEquals(4, lis.skip(7)); lis.reset(); assertEquals(2, lis.skip(2)); }
@Override public long skip(final long n) throws IOException { final long skipped = in.skip(Math.min(n, limit - bytesRead)); bytesRead += skipped; return skipped; }
LimitedInputStream extends InputStream { @Override public long skip(final long n) throws IOException { final long skipped = in.skip(Math.min(n, limit - bytesRead)); bytesRead += skipped; return skipped; } }
LimitedInputStream extends InputStream { @Override public long skip(final long n) throws IOException { final long skipped = in.skip(Math.min(n, limit - bytesRead)); bytesRead += skipped; return skipped; } LimitedInputStream(final InputStream in, final long limit); }
LimitedInputStream extends InputStream { @Override public long skip(final long n) throws IOException { final long skipped = in.skip(Math.min(n, limit - bytesRead)); bytesRead += skipped; return skipped; } LimitedInputStream(final InputStream in, final long limit); @Override int read(); @Override int read(final byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(final long n); @Override int available(); @Override void close(); @Override void mark(int readlimit); @Override boolean markSupported(); @Override void reset(); }
LimitedInputStream extends InputStream { @Override public long skip(final long n) throws IOException { final long skipped = in.skip(Math.min(n, limit - bytesRead)); bytesRead += skipped; return skipped; } LimitedInputStream(final InputStream in, final long limit); @Override int read(); @Override int read(final byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(final long n); @Override int available(); @Override void close(); @Override void mark(int readlimit); @Override boolean markSupported(); @Override void reset();  }