@Test public void skip() throws Exception { InputStream is = new UsbFileInputStream(file); long skipped = is.skip(50); assertEquals(50, skipped); is.read(new byte[1]); verify(file).read(longCaptor.capture(), byteBufferCaptor.capture()); assertEquals(50, longCaptor.getValue().longValue()); skipped = is.skip(100); assertEquals(123 - 50 - 1, skipped); }
@Override public long skip(long byteCount) throws IOException { long skippedBytes = Math.min(byteCount, file.getLength() - currentByteOffset); currentByteOffset += skippedBytes; return skippedBytes; }
UsbFileInputStream extends InputStream { @Override public long skip(long byteCount) throws IOException { long skippedBytes = Math.min(byteCount, file.getLength() - currentByteOffset); currentByteOffset += skippedBytes; return skippedBytes; } }
UsbFileInputStream extends InputStream { @Override public long skip(long byteCount) throws IOException { long skippedBytes = Math.min(byteCount, file.getLength() - currentByteOffset); currentByteOffset += skippedBytes; return skippedBytes; } UsbFileInputStream(UsbFile file); }
UsbFileInputStream extends InputStream { @Override public long skip(long byteCount) throws IOException { long skippedBytes = Math.min(byteCount, file.getLength() - currentByteOffset); currentByteOffset += skippedBytes; return skippedBytes; } UsbFileInputStream(UsbFile file); @Override int available(); @Override int read(); @Override void close(); @Override int read(byte[] buffer); @Override int read(byte[] buffer, int byteOffset, int byteCount); @Override long skip(long byteCount); }
UsbFileInputStream extends InputStream { @Override public long skip(long byteCount) throws IOException { long skippedBytes = Math.min(byteCount, file.getLength() - currentByteOffset); currentByteOffset += skippedBytes; return skippedBytes; } UsbFileInputStream(UsbFile file); @Override int available(); @Override int read(); @Override void close(); @Override int read(byte[] buffer); @Override int read(byte[] buffer, int byteOffset, int byteCount); @Override long skip(long byteCount);  }