Interface FileIOChannel
- All Known Subinterfaces:
BlockChannelReader<T>,BlockChannelWriter<T>,BlockChannelWriterWithCallback<T>,BufferFileReader,BufferFileSegmentReader,BufferFileWriter,BulkBlockChannelReader
- All Known Implementing Classes:
AbstractFileIOChannel,AsynchronousBlockReader,AsynchronousBlockWriter,AsynchronousBlockWriterWithCallback,AsynchronousBufferFileReader,AsynchronousBufferFileSegmentReader,AsynchronousBufferFileWriter,AsynchronousBulkBlockReader,AsynchronousFileIOChannel,SynchronousBufferFileReader,SynchronousFileIOChannel
public interface FileIOChannel
A Channel represents a collection of files that belong logically to the same resource. An example
is a collection of files that contain sorted runs of data from the same stream, that will later
on be merged together.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classAn enumerator for channels that logically belong together.static classAn ID identifying an underlying file channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the channel.voidCloses the channel and deletes the underlying file.voidDeletes the file underlying this I/O channel.Gets the channel ID of this I/O channel.longgetSize()Gets the size (in bytes) of the file underlying the channel.booleanisClosed()Checks whether the channel has been closed.
-
Method Details
-
getChannelID
FileIOChannel.ID getChannelID()Gets the channel ID of this I/O channel.- Returns:
- The channel ID.
-
getSize
Gets the size (in bytes) of the file underlying the channel.- Throws:
IOException
-
isClosed
boolean isClosed()Checks whether the channel has been closed.- Returns:
- True if the channel has been closed, false otherwise.
-
close
Closes the channel. For asynchronous implementations, this method waits until all pending requests are handled. Even if an exception interrupts the closing, the underlying FileChannel is closed.- Throws:
IOException- Thrown, if an error occurred while waiting for pending requests.
-
deleteChannel
void deleteChannel()Deletes the file underlying this I/O channel.- Throws:
IllegalStateException- Thrown, when the channel is still open.
-
getNioFileChannel
FileChannel getNioFileChannel() -
closeAndDelete
Closes the channel and deletes the underlying file. For asynchronous implementations, this method waits until all pending requests are handled.- Throws:
IOException- Thrown, if an error occurred while waiting for pending requests.
-