java.lang.Object
org.cojen.tupl.io.FileIO
- All Implemented Interfaces:
Closeable,AutoCloseable,CauseCloseable
Lowest I/O interface to a file or device.
-
Constructor Summary
Constructors -
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 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) abstract voidread(long pos, byte[] buf, int offset, int length, ByteBuffer tail) voidread(long pos, long ptr, int offset, int length) voidread(long pos, long ptr, int offset, int length, ByteBuffer tail) abstract voidread(long pos, ByteBuffer bb) abstract voidread(long pos, ByteBuffer bb, ByteBuffer tail) 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) abstract voidwrite(long pos, byte[] buf, int offset, int length, ByteBuffer tail) voidwrite(long pos, long ptr, int offset, int length) voidwrite(long pos, long ptr, int offset, int length, ByteBuffer tail) abstract voidwrite(long pos, ByteBuffer bb) abstract voidwrite(long pos, ByteBuffer bb, ByteBuffer tail) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cojen.tupl.io.CauseCloseable
close
-
Constructor Details
-
FileIO
public FileIO()
-
-
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
public abstract void read(long pos, byte[] buf, int offset, int length, ByteBuffer tail) throws IOException - Parameters:
pos- zero-based position in filebuf- receives read dataoffset- offset into data bufferlength- amount of data to readtail- receives additional data- Throws:
IllegalArgumentExceptionIOException
-
read
- Parameters:
pos- zero-based position in filebb- receives read data- Throws:
IllegalArgumentExceptionIOException
-
read
- Parameters:
pos- zero-based position in filebb- receives read datatail- receives additional data- Throws:
IllegalArgumentExceptionIOException
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
write
- Parameters:
pos- zero-based position in filebuf- data to writeoffset- offset into data bufferlength- amount of data- Throws:
IllegalArgumentExceptionIOException
-
write
public abstract void write(long pos, byte[] buf, int offset, int length, ByteBuffer tail) throws IOException - Parameters:
pos- zero-based position in filebuf- data to writeoffset- offset into data bufferlength- amount of datatail- additional data to write- Throws:
IllegalArgumentExceptionIOException
-
write
- Parameters:
pos- zero-based position in filebb- data to write- Throws:
IllegalArgumentExceptionIOException
-
write
- Parameters:
pos- zero-based position in filebb- data to writetail- additional data to write- Throws:
IllegalArgumentExceptionIOException
-
write
- Throws:
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
dirSync
Durably flushes the given directory, if required. If the given file is not a directory, the parent directory is flushed.- Throws:
IOException
-