### Question:
BufferedFileOutput implements RandomAccess, DataOutput, Flushable, Closeable { public void sync() throws IOException { int c = cursor; if (c > 0) { file.write(buffer, 0, c); cursor = 0; physicalPointer = -1L; } } 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();  }### Answer:
@Test public void testSync() throws Exception { RandomAccessFile file = file(); BufferedFileOutput buf = manage(new BufferedFileOutput(file, 100)); buf.sync(); file.write(1); buf.sync(); assertThat(buf.getPosition(), is(1L)); buf.write(2); buf.flush(); file.seek(0); assertThat(file.readByte(), is((byte) 1)); assertThat(file.readByte(), is((byte) 2)); eof(file); }