@Test public void testSkip() throws IOException { JimfsInputStream in = newInputStream(1, 2, 3, 4, 5, 6, 7, 8); assertThat(in.skip(0)).isEqualTo(0); assertThat(in.skip(-10)).isEqualTo(0); assertThat(in.skip(2)).isEqualTo(2); assertThat(in.read()).isEqualTo(3); assertThat(in.skip(3)).isEqualTo(3); assertThat(in.read()).isEqualTo(7); assertThat(in.skip(10)).isEqualTo(1); assertEmpty(in); assertThat(in.skip(10)).isEqualTo(0); assertEmpty(in); }
@Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } synchronized (this) { checkNotClosed(); if (finished) { return 0; } int skip = (int) Math.min(Math.max(file.size() - pos, 0), n); pos += skip; return skip; } }
JimfsInputStream extends InputStream { @Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } synchronized (this) { checkNotClosed(); if (finished) { return 0; } int skip = (int) Math.min(Math.max(file.size() - pos, 0), n); pos += skip; return skip; } } }
JimfsInputStream extends InputStream { @Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } synchronized (this) { checkNotClosed(); if (finished) { return 0; } int skip = (int) Math.min(Math.max(file.size() - pos, 0), n); pos += skip; return skip; } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); }
JimfsInputStream extends InputStream { @Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } synchronized (this) { checkNotClosed(); if (finished) { return 0; } int skip = (int) Math.min(Math.max(file.size() - pos, 0), n); pos += skip; return skip; } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); @Override synchronized int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override synchronized int available(); @Override synchronized void close(); }
JimfsInputStream extends InputStream { @Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } synchronized (this) { checkNotClosed(); if (finished) { return 0; } int skip = (int) Math.min(Math.max(file.size() - pos, 0), n); pos += skip; return skip; } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); @Override synchronized int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override synchronized int available(); @Override synchronized void close();  }