UnsafeStringReader extends Reader { @Override public long skip(long ns) throws IOException { ensureOpen(); if (mPosition >= mLimit) { return 0; } long n = Math.min(mLimit - mPosition, ns); n = Math.max(-mPosition, n); mPosition += n; return n; } UnsafeStringReader(String str); @Override int read(); @Override int read(char[] cs, int off, int len); @Override long skip(long ns); @Override boolean ready(); @Override boolean markSupported(); @Override void mark(int readAheadLimit); @Override void reset(); @Override void close();  }
@Test public void testSkip() throws IOException { UnsafeStringReader reader = new UnsafeStringReader("abc"); assertThat(reader.ready(), is(true)); reader.skip(1); assertThat(reader.read(), is((int) 'b')); }
@Test public void testSkipTooLong() throws IOException { UnsafeStringReader reader = new UnsafeStringReader("abc"); reader.skip(10); long skip = reader.skip(10); assertThat(skip, is(0L)); }