Class FileIO
java.lang.Object
org.cojen.tupl.io.FileIO
- All Implemented Interfaces:
Closeable
,AutoCloseable
,CauseCloseable
Lowest I/O interface to a file or device.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static void
Durably flushes the given directory, if required.void
expandLength
(long length) Attempt to expand the length of the file.abstract void
expandLength
(long length, LengthOption option) Attempt to expand the length of the file.abstract boolean
isClosed()
abstract boolean
abstract boolean
abstract long
length()
abstract void
map()
Maps or remaps the file into main memory, up to the current file length.static FileIO
open
(File file, EnumSet<OpenOption> options) static FileIO
open
(File file, EnumSet<OpenOption> options, int openFileCount) abstract void
read
(long pos, byte[] buf, int offset, int length) void
read
(long pos, long addr, int offset, int length) abstract void
remap()
If file is mapped, remaps it if the file length has changed.abstract void
sync
(boolean metadata) Durably flushes all writes to the underlying device.abstract void
truncateLength
(long length) Attempt to truncate the length of the file.abstract void
unmap()
Unmaps the file from main memory, leaving the file open.abstract void
write
(long pos, byte[] buf, int offset, int length) void
write
(long pos, long addr, int offset, int length) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cojen.tupl.io.CauseCloseable
close
-
Method Details
-
open
- Throws:
IOException
-
open
public static FileIO open(File file, EnumSet<OpenOption> options, int openFileCount) throws IOException - Throws:
IOException
-
isDirectIO
public abstract boolean isDirectIO() -
isReadOnly
public abstract boolean isReadOnly() -
length
- Throws:
IOException
-
truncateLength
Attempt to truncate the length of the file. It isn't critical that the operation succeed, and so any exceptions can be suppressed.- Throws:
IOException
-
expandLength
Attempt to expand the length of the file. It isn't critical that the operation succeed, and so any exceptions can be suppressed.- Throws:
IOException
-
expandLength
Attempt to expand the length of the file. It isn't critical that the operation succeed, and so any exceptions can be suppressed.- Throws:
IOException
-
read
- Parameters:
pos
- zero-based position in filebuf
- receives read dataoffset
- offset into data bufferlength
- amount of data to read- Throws:
IllegalArgumentException
IOException
-
read
- Throws:
IOException
-
write
- Parameters:
pos
- zero-based position in filebuf
- data to writeoffset
- offset into data bufferlength
- amount of data- Throws:
IllegalArgumentException
IOException
-
write
- Throws:
IOException
-
map
Maps or remaps the file into main memory, up to the current file length.- Throws:
IOException
-
remap
If file is mapped, remaps it if the file length has changed. Method does nothing if not already mapped.- Throws:
IOException
-
unmap
Unmaps the file from main memory, leaving the file open. Method does nothing if not already mapped.- Throws:
IOException
-
sync
Durably flushes all writes to the underlying device.- Parameters:
metadata
- pass true to flush all file metadata- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isClosed
public abstract boolean isClosed() -
dirSync
Durably flushes the given directory, if required. If the given file is not a directory, the parent directory is flushed.- Throws:
IOException
-