@SuppressWarnings("CheckReturnValue") // calling read() to skip a byte public void testMark() throws Exception { assertTrue(counter.markSupported()); assertEquals(10, counter.read(new byte[10])); assertEquals(10, counter.getCount()); counter.mark(5); counter.read(); assertEquals(11, counter.getCount()); counter.reset(); assertEquals(10, counter.getCount()); assertEquals(10, counter.skip(100)); assertEquals(20, counter.getCount()); }
/** * A CountingInputStream is inserted to read compressed-offsets. * * @param in stream to wrap * @param lookback tolerance of initial mark * @return original stream wrapped in CountingInputStream * @throws IOException */ protected static InputStream countingStream(InputStream in, int lookback) throws IOException { CountingInputStream cin = new CountingInputStream(in); cin.mark(lookback); return cin; }
/** * A CountingInputStream is inserted to read compressed-offsets. * * @param in stream to wrap * @param lookback tolerance of initial mark * @return original stream wrapped in CountingInputStream * @throws IOException */ protected static InputStream countingStream(InputStream in, int lookback) throws IOException { CountingInputStream cin = new CountingInputStream(in); cin.mark(lookback); return cin; }
@SuppressWarnings("CheckReturnValue") // calling read() to skip a byte public void testMark() throws Exception { assertTrue(counter.markSupported()); assertEquals(10, counter.read(new byte[10])); assertEquals(10, counter.getCount()); counter.mark(5); counter.read(); assertEquals(11, counter.getCount()); counter.reset(); assertEquals(10, counter.getCount()); assertEquals(10, counter.skip(100)); assertEquals(20, counter.getCount()); }
/** * A CountingInputStream is inserted to read compressed-offsets. * * @param in stream to wrap * @param lookback tolerance of initial mark * @return original stream wrapped in CountingInputStream * @throws IOException */ protected static InputStream countingStream(InputStream in, int lookback) throws IOException { CountingInputStream cin = new CountingInputStream(in); cin.mark(lookback); return cin; }
final CountingInputStream bufferedInputStream = new CountingInputStream(inputStream); try { bufferedInputStream.mark(0); final T signable = signableDeserializingFactory.consume(bufferedInputStream);