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 TypeMethodDescriptionvoidclose()static voidDurably flushes the given directory, if required.voidexpandLength(long length) Attempt to expand the length of the file.abstract voidexpandLength(long length, LengthOption option) Attempt to expand the length of the file.abstract booleanisClosed()abstract booleanabstract booleanabstract longlength()abstract voidmap()Maps or remaps the file into main memory, up to the current file length.static FileIOopen(File file, EnumSet<OpenOption> options) static FileIOopen(File file, EnumSet<OpenOption> options, int openFileCount) abstract voidread(long pos, byte[] buf, int offset, int length) voidread(long pos, long addr, int offset, int length) abstract voidremap()If file is mapped, remaps it if the file length has changed.abstract voidsync(boolean metadata) Durably flushes all writes to the underlying device.abstract voidtruncateLength(long length) Attempt to truncate the length of the file.abstract voidunmap()Unmaps the file from main memory, leaving the file open.abstract voidwrite(long pos, byte[] buf, int offset, int length) voidwrite(long pos, long addr, int offset, int length) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
IllegalArgumentExceptionIOException
-
read
- Throws:
IOException
-
write
- Parameters:
pos- zero-based position in filebuf- data to writeoffset- offset into data bufferlength- amount of data- Throws:
IllegalArgumentExceptionIOException
-
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:
closein interfaceAutoCloseable- Specified by:
closein 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
-