@Test public void testSkipBytes() throws Exception { RandomAccessFile file = file(); byte[] data = range(0, 1023); file.write(data); file.seek(0); BufferedFileInput buf = manage(new BufferedFileInput(file, 256)); buf.readByte(); buf.seek(0); assertThat(buf.skipBytes(10), is(10)); assertThat(buf.getPosition(), is(10L)); assertThat(buf.skipBytes(300), is(300)); assertThat(buf.getPosition(), is(310L)); assertThat(buf.readByte(), is((byte) 310)); }
@Override public int skipBytes(int n) throws IOException { int result = 0; if (offset < limit) { result = Math.min(n, limit - offset); offset += result; } if (result < n) { int skip = file.skipBytes(n - result); if (skip > 0 && physicalPointer >= 0) { physicalPointer += skip; } return result + skip; } else { return result; } }
BufferedFileInput implements RandomAccess, DataInput, Closeable { @Override public int skipBytes(int n) throws IOException { int result = 0; if (offset < limit) { result = Math.min(n, limit - offset); offset += result; } if (result < n) { int skip = file.skipBytes(n - result); if (skip > 0 && physicalPointer >= 0) { physicalPointer += skip; } return result + skip; } else { return result; } } }
BufferedFileInput implements RandomAccess, DataInput, Closeable { @Override public int skipBytes(int n) throws IOException { int result = 0; if (offset < limit) { result = Math.min(n, limit - offset); offset += result; } if (result < n) { int skip = file.skipBytes(n - result); if (skip > 0 && physicalPointer >= 0) { physicalPointer += skip; } return result + skip; } else { return result; } } BufferedFileInput(RandomAccessFile file, int bufferSize);  BufferedFileInput(RandomAccessFile file, byte[] buffer); }
BufferedFileInput implements RandomAccess, DataInput, Closeable { @Override public int skipBytes(int n) throws IOException { int result = 0; if (offset < limit) { result = Math.min(n, limit - offset); offset += result; } if (result < n) { int skip = file.skipBytes(n - result); if (skip > 0 && physicalPointer >= 0) { physicalPointer += skip; } return result + skip; } else { return result; } } BufferedFileInput(RandomAccessFile file, int bufferSize);  BufferedFileInput(RandomAccessFile file, byte[] buffer); void sync(); void seek(long position); long getPosition(); long getSize(); @Override void readFully(byte[] b); @Override void readFully(byte[] b, int off, int len); @Override int skipBytes(int n); @Override boolean readBoolean(); @Override short readShort(); @Override byte readByte(); @Override int readInt(); @Override long readLong(); @Override float readFloat(); @Override double readDouble(); @Override int readUnsignedByte(); @Override int readUnsignedShort(); @Override char readChar(); @Override String readLine(); @Override String readUTF(); @Override void close(); }
BufferedFileInput implements RandomAccess, DataInput, Closeable { @Override public int skipBytes(int n) throws IOException { int result = 0; if (offset < limit) { result = Math.min(n, limit - offset); offset += result; } if (result < n) { int skip = file.skipBytes(n - result); if (skip > 0 && physicalPointer >= 0) { physicalPointer += skip; } return result + skip; } else { return result; } } BufferedFileInput(RandomAccessFile file, int bufferSize);  BufferedFileInput(RandomAccessFile file, byte[] buffer); void sync(); void seek(long position); long getPosition(); long getSize(); @Override void readFully(byte[] b); @Override void readFully(byte[] b, int off, int len); @Override int skipBytes(int n); @Override boolean readBoolean(); @Override short readShort(); @Override byte readByte(); @Override int readInt(); @Override long readLong(); @Override float readFloat(); @Override double readDouble(); @Override int readUnsignedByte(); @Override int readUnsignedShort(); @Override char readChar(); @Override String readLine(); @Override String readUTF(); @Override void close();  }