private long countBySkipping(Reader reader) throws IOException { long count = 0; long read; while ((read = reader.skip(Long.MAX_VALUE)) != 0) { count += read; } return count; }
private long countBySkipping(Reader reader) throws IOException { long count = 0; long read; while ((read = reader.skip(Long.MAX_VALUE)) != 0) { count += read; } return count; }
private long countBySkipping(Reader reader) throws IOException { long count = 0; long read; while ((read = reader.skip(Long.MAX_VALUE)) != 0) { count += read; } return count; }
@Override public long skip(long n) throws IOException { if (n > limit) { n = (int) limit; } n = r.skip(n); limit -= n; return n; }
private long countBySkipping(Reader reader) throws IOException { long count = 0; long read; while ((read = reader.skip(Long.MAX_VALUE)) != 0) { count += read; } return count; }
@Override public long skip(long n) throws IOException { return wrappedReader.skip(n); }
/** * Discards {@code n} characters of data from the reader. This method will block until the full * amount has been skipped. Does not close the reader. * * @param reader the reader to read from * @param n the number of characters to skip * @throws EOFException if this stream reaches the end before skipping all the characters * @throws IOException if an I/O error occurs */ public static void skipFully(Reader reader, long n) throws IOException { checkNotNull(reader); while (n > 0) { long amt = reader.skip(n); if (amt == 0) { throw new EOFException(); } n -= amt; } }
public long skip(long i) throws java.io.IOException { return in.skip(i); }
/** @see java.io.Reader#skip(long) */ public long skip(long ln) throws IOException { return in.skip(ln); }
@Override public long skip(long n) throws IOException { Preconditions.checkArgument(n >= 0, "n is negative"); if (n > 0) { while (current != null) { long result = current.skip(n); if (result > 0) { return result; } advance(); } } return 0; }
/** * Discards {@code n} characters of data from the reader. This method will block until the full * amount has been skipped. Does not close the reader. * * @param reader the reader to read from * @param n the number of characters to skip * @throws EOFException if this stream reaches the end before skipping all the characters * @throws IOException if an I/O error occurs */ public static void skipFully(Reader reader, long n) throws IOException { checkNotNull(reader); while (n > 0) { long amt = reader.skip(n); if (amt == 0) { throw new EOFException(); } n -= amt; } }
/** * Invokes the delegate's <code>skip(long)</code> method. * @param ln the number of bytes to skip * @return the number of bytes to skipped or EOF if the end of stream * @throws IOException if an I/O error occurs */ @Override public long skip(final long ln) throws IOException { try { return in.skip(ln); } catch (final IOException e) { handleIOException(e); return 0; } }
@Override public long skip(long n) throws IOException { Preconditions.checkArgument(n >= 0, "n is negative"); if (n > 0) { while (current != null) { long result = current.skip(n); if (result > 0) { return result; } advance(); } } return 0; }
/** * Discards {@code n} characters of data from the reader. This method will block until the full * amount has been skipped. Does not close the reader. * * @param reader the reader to read from * @param n the number of characters to skip * @throws EOFException if this stream reaches the end before skipping all the characters * @throws IOException if an I/O error occurs */ public static void skipFully(Reader reader, long n) throws IOException { checkNotNull(reader); while (n > 0) { long amt = reader.skip(n); if (amt == 0) { throw new EOFException(); } n -= amt; } }
@Override public long skip(long n) throws IOException { Preconditions.checkArgument(n >= 0, "n is negative"); if (n > 0) { while (current != null) { long result = current.skip(n); if (result > 0) { return result; } advance(); } } return 0; }
@Override public long skip(long n) throws IOException { Preconditions.checkArgument(n >= 0, "n is negative"); if (n > 0) { while (current != null) { long result = current.skip(n); if (result > 0) { return result; } advance(); } } return 0; }
@Override public long skip( long n ) throws IOException { adversary.injectFailure( IllegalArgumentException.class, IOException.class ); return reader.skip( n ); }
@Test public void testSkip() throws IOException { final Reader reader = new CharSequenceReader("FooBar"); assertEquals(3, reader.skip(3)); checkRead(reader, "Bar"); assertEquals(-1, reader.skip(3)); reader.reset(); assertEquals(2, reader.skip(2)); assertEquals(4, reader.skip(10)); assertEquals(-1, reader.skip(1)); reader.close(); assertEquals(6, reader.skip(20)); assertEquals(-1, reader.read()); }
public void testSkipZero() throws Exception { CharSource source = newCharSource("a"); Iterable<CharSource> list = ImmutableList.of(source, source); Reader joinedReader = CharSource.concat(list).openStream(); assertEquals(0, joinedReader.skip(0)); assertEquals('a', joinedReader.read()); } }
@Test public void testSkip() throws Exception { final Reader reader = new TestNullReader(10, true, false); assertEquals("Read 1", 0, reader.read()); assertEquals("Read 2", 1, reader.read()); assertEquals("Skip 1", 5, reader.skip(5)); assertEquals("Read 3", 7, reader.read()); assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file try { reader.skip(5); // fail("Expected IOException for skipping after end of file"); } catch (final IOException e) { assertEquals("Skip after EOF IOException message", "Skip after end of file", e.getMessage()); } reader.close(); }