public class RandomAccessFileIO extends AbstractFileIO
FileChannel.| Constructor and Description |
|---|
RandomAccessFileIO(File file,
OpenOption... modes)
Creates I/O implementation for specified
file |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Truncates current file to zero length
and resets current file position to zero.
|
void |
close()
Closes current file.
|
void |
force()
Forces any updates of this file to be written to the storage
device that contains it.
|
void |
force(boolean withMetadata)
Forces any updates of this file to be written to the storage
device that contains it.
|
int |
getFileSystemBlockSize() |
long |
getSparseSize() |
MappedByteBuffer |
map(int sizeBytes)
Allocates memory mapped buffer for this file with given size.
|
long |
position()
Returns current file position.
|
void |
position(long newPosition)
Sets new current file position.
|
int |
punchHole(long position,
int len) |
int |
read(byte[] buf,
int off,
int len)
Reads a up to
length bytes from this file into the buffer. |
int |
read(ByteBuffer destBuf)
Reads a sequence of bytes from this file into the
destinationBuffer. |
int |
read(ByteBuffer destBuf,
long position)
Reads a sequence of bytes from this file into the
destinationBuffer
starting from specified file position. |
long |
size()
Returns current file size in bytes.
|
long |
transferFrom(ReadableByteChannel src,
long position,
long count) |
long |
transferTo(long position,
long count,
WritableByteChannel target)
This method will transfers the content of file to the specified channel.
|
int |
write(byte[] buf,
int off,
int len)
Writes
length bytes from the buffer
starting at offset off to this file. |
int |
write(ByteBuffer srcBuf)
Writes a sequence of bytes to this file from the
sourceBuffer. |
int |
write(ByteBuffer srcBuf,
long position)
Writes a sequence of bytes to this file from the
sourceBuffer
starting from specified file position |
readFully, readFully, readFully, writeFully, writeFully, writeFullypublic RandomAccessFileIO(File file, OpenOption... modes) throws IOException
filefile - File.modes - Open modes.IOExceptionpublic int getFileSystemBlockSize()
public long getSparseSize()
FileIO.punchHole(long, int)public int punchHole(long position,
int len)
position - Starting file position.len - Number of bytes to free.public long position()
throws IOException
IOException - If some I/O error occurs.public void position(long newPosition)
throws IOException
newPosition - The new position, a non-negative integer counting
the number of bytes from the beginning of the file.IOException - If some I/O error occurs.public int read(ByteBuffer destBuf) throws IOException
destinationBuffer.destBuf - Destination byte buffer.IOException - If some I/O error occurs.public int read(ByteBuffer destBuf, long position) throws IOException
destinationBuffer
starting from specified file position.destBuf - Destination byte buffer.position - Starting position of file.IOException - If some I/O error occurs.public int read(byte[] buf,
int off,
int len)
throws IOException
length bytes from this file into the buffer.buf - Destination byte array.off - The start offset in array b
at which the data is written.len - Maximum number of bytes read.IOException - If some I/O error occurs.public int write(ByteBuffer srcBuf) throws IOException
sourceBuffer.srcBuf - Source buffer.IOException - If some I/O error occurs.public int write(ByteBuffer srcBuf, long position) throws IOException
sourceBuffer
starting from specified file positionsrcBuf - Source buffer.position - Starting file position.IOException - If some I/O error occurs.public int write(byte[] buf,
int off,
int len)
throws IOException
length bytes from the buffer
starting at offset off to this file.buf - Source byte array.off - Start offset in the buffer.len - Number of bytes to write.IOException - If some I/O error occurs.public void force(boolean withMetadata)
throws IOException
withMetadata - If true force also file metadata.IOException - If some I/O error occurs.public long size()
throws IOException
IOException - If some I/O error occurs.public void clear()
throws IOException
IOException - If some I/O error occurs.public void close()
throws IOException
IOException - If some I/O error occurs.public MappedByteBuffer map(int sizeBytes) throws IOException
sizeBytes - Size of buffer.IOException - If some I/O error occurs.public void force()
throws IOException
IOException - If some I/O error occurs.public long transferTo(long position,
long count,
WritableByteChannel target)
throws IOException
position - The relative offset of the file where the transfer begins from.count - The number of bytes to be transferred.target - Destination channel of the transfer.IOException - If fails.public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
src - The source channel.position - The position within the file at which the transfer is to begin.count - The maximum number of bytes to be transferred.IOException - If fails.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.8.1 Release Date : May 21 2020