I have a class works like FilterOutputStream
.
public class WritableFilterChannel implements WritableChannel {
public WritableFilterChannel(final WritableByteChannel channel) {
super();
this.channel = channel;
}
// isOpen(), close() delegates to the channel
// write(ByteBuffer) overridden to work differently
protected WritableByteChannel channel;
}
When I pass an instance of FileChannel
, there is no way to force()
other than close()
it.
Is FileChannel#force
is equivalent to OutputStream#flush
? Do I always have to call it?
Do I have to do like this?
@Override
public void close() {
if (channel instanceof FileChannel) throws IOException {
((FileChannel) channel).force(); // general solution?
}
channel.close();
}