Package org.jtrim2.concurrent.query.io
Class FileChannelOpener
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
ConstructorsConstructorDescriptionFileChannelOpener(Path fileToOpen) Creates aFileChannelOpenerwhich will open the specified file when requested. -
Method Summary
Modifier and TypeMethodDescriptionOpens a new channel to the source defined by thisChannelOpenerinstance.
-
Constructor Details
-
FileChannelOpener
Creates aFileChannelOpenerwhich 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 thisChannelOpenerinstance. This method opens a new channel each time called an these opened channels must beclosedseparately.Implementation note: The file channel will be opened for reading only. That is, with the
StandardOpenOption.READ.- Specified by:
openChanelin interfaceChannelOpener<FileChannel>- Returns:
- new channel to the source defined by this
ChannelOpenerinstance. The returned instance must beclosedin order to prevent resource leakage. This method never returnsnull. - Throws:
IOException- thrown if the channel could not be opened for some reasons
-