public abstract class AbstractFileIOChannel extends Object implements FileIOChannel
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 |
---|---|
abstract 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.
|
abstract 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()
FileIOChannel
getChannelID
in interface FileIOChannel
public long getSize() throws IOException
FileIOChannel
getSize
in interface FileIOChannel
IOException
public abstract boolean isClosed()
FileIOChannel
isClosed
in interface FileIOChannel
public abstract void close() throws IOException
FileIOChannel
close
in interface FileIOChannel
IOException
- Thrown, if an error occurred while waiting for pending requests.public void deleteChannel()
FileIOChannel
deleteChannel
in interface FileIOChannel
public void closeAndDelete() throws IOException
FileIOChannel
closeAndDelete
in interface FileIOChannel
IOException
- Thrown, if an error occurred while waiting for pending requests.public FileChannel getNioFileChannel()
getNioFileChannel
in interface FileIOChannel
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.