I have a class works like FilterOutputStream
.
public class WritableFilterChannel implements WritableChannel
"Equivalent" is too strong a word. FileChannel.force(false)
is similar to OutputStream.flush()
. FileChannel's force() method offers stronger guarantees about the state of the file after it returns than OutputStream's flush() method.
Obviously you do not have to close() the FileChannel that you called the force() method on. You should only close the channel when you have finished with it. However, there is no guarantee that closing the channel will cause the equivalent of a force operation on it. If you need the behavior that force() specifies as part of the channel closure then you must explicitly call it the way you are doing in your close() method.