java.lang.Object
org.jtrim2.concurrent.query.io.FileChannelOpener
- All Implemented Interfaces:
ChannelOpener<FileChannel>
Defines a
ChannelOpener
which opens a specific file. The file is
always opened for reading only. The file must exists when requested to be
opened otherwise FileChannelOpener
will fail to open the file.
Thread safety
As required by theChannelOpener
, this class is safe to be accessed
by multiple threads concurrently.
Synchronization transparency
Methods of this class are not synchronization transparent.- See Also:
-
Constructor Summary
ConstructorDescriptionFileChannelOpener
(Path fileToOpen) Creates aFileChannelOpener
which will open the specified file when requested. -
Method Summary
Modifier and TypeMethodDescriptionOpens a new channel to the source defined by thisChannelOpener
instance.
-
Constructor Details
-
FileChannelOpener
Creates aFileChannelOpener
which will open the specified file when requested.- Parameters:
fileToOpen
- the file to open when requested. This argument cannot benull
- Throws:
NullPointerException
- thrown if the specified path isnull
-
-
Method Details
-
openChanel
Opens a new channel to the source defined by thisChannelOpener
instance. This method opens a new channel each time called an these opened channels must beclosed
separately.Implementation note: The file channel will be opened for reading only. That is, with the
StandardOpenOption.READ
.- Specified by:
openChanel
in interfaceChannelOpener<FileChannel>
- Returns:
- new channel to the source defined by this
ChannelOpener
instance. The returned instance must beclosed
in order to prevent resource leakage. This method never returnsnull
. - Throws:
IOException
- thrown if the channel could not be opened for some reasons
-