Class CleanableFileChannel

java.lang.Object
org.fairdatapipeline.file.CleanableFileChannel
All Implemented Interfaces:
Closeable, AutoCloseable, ByteChannel, Channel, GatheringByteChannel, ReadableByteChannel, ScatteringByteChannel, SeekableByteChannel, WritableByteChannel

public class CleanableFileChannel extends Object implements AutoCloseable, SeekableByteChannel, GatheringByteChannel, ScatteringByteChannel
Wrapper around standard FileChannel with additional safety net for closing if user does not close and ability to run custom function during cleanup/closing. Users should either use with try-with-resources or ensure they manually call .close() once finished. As a safety net, .close() will be called by a cleaner if and when the instance of CleanableFileChannel is going to be collected by GC.