Obtains a ByteChannel for read/write access to the file.
Obtains a ByteChannel for read/write access to the file. If no OpenOptions are specified the underlying file will be opened with read/write/create/truncate options.
The Resource will be configured with the associated fileSystem's ResourceContext
All OpenOption
can be used
the options that define how the file is opened when using the stream Default is options only
Obtains a FileChannel for read/write access to the file.
Obtains a FileChannel for read/write access to the file. Not all filesystems can support FileChannels therefore None will be returned if the filesystem does not support FileChannels. If no OpenOptions are specified the underlying file will be opened with read/write/create/truncate options
All OpenOption
can be used
The Resource will be configured with the associated fileSystem's ResourceContext
the options that define how the file is opened when using the stream Default is read/write/create/truncate
Obtains an input stream resource for reading from the file
Obtains an input stream resource for reading from the file
The Resource will be configured with the associated fileSystem's ResourceContext
Obtains an OutputStreamResource for writing to the file
Obtains an OutputStreamResource for writing to the file
The Resource will be configured with the associated fileSystem's ResourceContext
All OpenOption
can be used except Read which will be ignored if present
the options that define how the file is opened when using the stream The Write option is implicitly added to the set of options Default is write/create/truncate
Performs an operation on the file with a FileLock
Performs an operation on the file with a FileLock
Not all filesystems support locking. If not then None will be returned by the method
The defaults will lock the entire file with an exclusive lock. It is possible to modify the lock so that it only locks part of the file and may be a shared lock. Not all filesystems support shared locks but if that is the case the lock will automatically be upgraded to a exclusiveLock
The semantics of this locking behavious are very similar to those in the java.nio.channels.FileLock
It is recommended that those javadocs are read and the warnings present in those docs are followed.
the start position of the lock. Must be a non-negative Long
the length in bits the lock. If -1 then the entire file from start to the end will be locked
If true then a shared lock will be obtained if possible. If shared locks are not supported then an exclusive lock will be obtained
The context for controlling buffer sizes error handling and other low level configuration
the result the result from the block or None if the filesystem does not support locking
Runs several operations as efficiently as possible.
Runs several operations as efficiently as possible. If the filesystem permits random access then the same channel will be used to perform all operations.
Note: only the direct file operations (bytes,lines,write,patch etc...) can be used and expected to use the same resource. The resource methods all created new streams.
Note: not all file systems support this, if not then at worst the performance is the same as if they where performed outside an open block
The options that define how the file is opened for the duration of the operation Default is Write/Create/Truncate
The context for controlling buffer sizes error handling and other low level configuration defaults to filesystem Resource context
An object for reading and writing files. FileOps provides access to Channels and streams as well as providing methods for performing simple tasks on files easily.
Obtaining a FileOps from a object does not open a file execution of methods will open a file. Thus it is important to handle NotFileException and FileNotFoundException. Depending on the method one or both exceptions must be handled.
Examples of exception handling:
or using the Exceptions objectThe API into 3 main sections
open() attempts to perform all actions using the open channel in order to improve the performance of the operations.
lock() performs all the actions using the same channel
1.0