@Test public void testSeek() throws Exception { RandomAccessFile file = file(); BufferedFileOutput buf = manage(new BufferedFileOutput(file, 256)); buf.write(range(0, 99)); buf.seek(1); assertThat(buf.getPosition(), is(1L)); buf.write(-1); buf.seek(2); buf.flush(); file.seek(0); assertThat(file.readByte(), is((byte) 0)); assertThat(file.readByte(), is((byte) -1)); for (int i = 2; i < 100; i++) { assertThat(file.readByte(), is((byte) i)); } }
public void seek(long position) throws IOException { if (position == getPosition()) { return; } sync(); file.seek(position); }
BufferedFileOutput implements RandomAccess, DataOutput, Flushable, Closeable { public void seek(long position) throws IOException { if (position == getPosition()) { return; } sync(); file.seek(position); } }
BufferedFileOutput implements RandomAccess, DataOutput, Flushable, Closeable { public void seek(long position) throws IOException { if (position == getPosition()) { return; } sync(); file.seek(position); } BufferedFileOutput(RandomAccessFile file, int bufferSize);  BufferedFileOutput(RandomAccessFile file, byte[] buffer); }
BufferedFileOutput implements RandomAccess, DataOutput, Flushable, Closeable { public void seek(long position) throws IOException { if (position == getPosition()) { return; } sync(); file.seek(position); } BufferedFileOutput(RandomAccessFile file, int bufferSize);  BufferedFileOutput(RandomAccessFile file, byte[] buffer); void sync(); void seek(long position); long getPosition(); long getSize(); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void writeBoolean(boolean v); @Override void writeByte(int v); @Override void writeShort(int v); @Override void writeChar(int v); @Override void writeInt(int v); @Override void writeLong(long v); @Override void writeFloat(float v); @Override void writeDouble(double v); @Override void writeBytes(String s); @Override void writeChars(String s); @Override void writeUTF(String s); @Override void flush(); @Override void close(); }
BufferedFileOutput implements RandomAccess, DataOutput, Flushable, Closeable { public void seek(long position) throws IOException { if (position == getPosition()) { return; } sync(); file.seek(position); } BufferedFileOutput(RandomAccessFile file, int bufferSize);  BufferedFileOutput(RandomAccessFile file, byte[] buffer); void sync(); void seek(long position); long getPosition(); long getSize(); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void writeBoolean(boolean v); @Override void writeByte(int v); @Override void writeShort(int v); @Override void writeChar(int v); @Override void writeInt(int v); @Override void writeLong(long v); @Override void writeFloat(float v); @Override void writeDouble(double v); @Override void writeBytes(String s); @Override void writeChars(String s); @Override void writeUTF(String s); @Override void flush(); @Override void close();  }