public abstract class AbstractFileIOChannel extends Object implements FileIOChannel
FileIOChannel to share some implementation.FileIOChannel.Enumerator, FileIOChannel.ID| Modifier and Type | Field and Description |
|---|---|
protected FileChannel |
fileChannel
A file channel for NIO access to the file.
|
protected FileIOChannel.ID |
id
The ID of the underlying channel.
|
protected static org.slf4j.Logger |
LOG
Logger object for channel and its subclasses.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractFileIOChannel(FileIOChannel.ID channelID,
boolean writeEnabled)
Creates a new channel to the path indicated by the given ID.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the channel.
|
void |
closeAndDelete()
Closes the channel and deletes the underlying file.
|
void |
deleteChannel()
Deletes the file underlying this I/O channel.
|
FileIOChannel.ID |
getChannelID()
Gets the channel ID of this I/O channel.
|
FileChannel |
getNioFileChannel() |
long |
getSize()
Gets the size (in bytes) of the file underlying the channel.
|
boolean |
isClosed()
Checks whether the channel has been closed.
|
protected static final org.slf4j.Logger LOG
protected final FileIOChannel.ID id
protected final FileChannel fileChannel
protected AbstractFileIOChannel(FileIOChannel.ID channelID, boolean writeEnabled) throws IOException
channelID - The id describing the path of the file that the channel accessed.writeEnabled - Flag describing whether the channel should be opened in read/write mode,
rather than in read-only mode.IOException - Thrown, if the channel could no be opened.public final FileIOChannel.ID getChannelID()
FileIOChannelgetChannelID in interface FileIOChannelpublic long getSize()
throws IOException
FileIOChannelgetSize in interface FileIOChannelIOExceptionpublic boolean isClosed()
FileIOChannelisClosed in interface FileIOChannelpublic void close()
throws IOException
FileIOChannelclose in interface FileIOChannelIOException - Thrown, if an error occurred while waiting for pending requests.public void deleteChannel()
FileIOChanneldeleteChannel in interface FileIOChannelpublic void closeAndDelete()
throws IOException
FileIOChannelcloseAndDelete in interface FileIOChannelIOException - Thrown, if an error occurred while waiting for pending requests.public FileChannel getNioFileChannel()
getNioFileChannel in interface FileIOChannelCopyright © 2023–2024 The Apache Software Foundation. All rights reserved.