public class RandomAccessReadMemoryMappedFile extends Object implements RandomAccessRead
| Constructor and Description |
|---|
RandomAccessReadMemoryMappedFile(File file)
Create a random access memory mapped file instance for the given file.
|
RandomAccessReadMemoryMappedFile(Path path)
Create a random access memory mapped file instance using the given path.
|
RandomAccessReadMemoryMappedFile(String filename)
Create a random access memory mapped file instance for the file with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
RandomAccessReadView |
createView(long startPosition,
long streamLength)
Creates a random access read view starting at the given position with the given length.
|
long |
getPosition()
Returns offset of next byte to be returned by a read method.
|
boolean |
isClosed()
Returns true if this source has been closed.
|
boolean |
isEOF()
A simple test to see if we are at the end of the data.
|
long |
length()
The total number of bytes that are available.
|
int |
read()
Read a single byte of data.
|
int |
read(byte[] b,
int offset,
int length)
Read a buffer of data.
|
void |
seek(long position)
Seek to a position in the data.
|
public RandomAccessReadMemoryMappedFile(String filename) throws IOException
filename - the filename of the file to be readIOException - If there is an IO error opening the file.public RandomAccessReadMemoryMappedFile(File file) throws IOException
file - the file to be readIOException - If there is an IO error opening the file.public RandomAccessReadMemoryMappedFile(Path path) throws IOException
path - path of the file to be read.IOException - If there is an IO error opening the file.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void seek(long position)
throws IOException
seek in interface RandomAccessReadposition - The position to seek to.IOException - If there is an error while seeking.public long getPosition()
throws IOException
getPosition in interface RandomAccessReadRandomAccessRead.read() (if no more bytes are left it
returns a value >= length of source)IOException - If there was an error while getting the current positionpublic int read()
throws IOException
read in interface RandomAccessReadIOException - If there is an error while reading the data.public int read(byte[] b,
int offset,
int length)
throws IOException
read in interface RandomAccessReadb - The buffer to write the data to.offset - Offset into the buffer to start writing.length - The amount of data to attempt to read.IOException - If there was an error while reading the data.public long length()
throws IOException
length in interface RandomAccessReadIOException - If there is an IO error while determining the length of the data stream.public boolean isClosed()
isClosed in interface RandomAccessReadpublic boolean isEOF()
throws IOException
isEOF in interface RandomAccessReadIOException - If there is an error reading the next byte.public RandomAccessReadView createView(long startPosition, long streamLength)
RandomAccessReadcreateView in interface RandomAccessReadstartPosition - start position within the underlying random access readstreamLength - stream lengthCopyright © 2002–2025 The Apache Software Foundation. All rights reserved.