public final class MemoryMappedFile extends Object implements AutoCloseable
#mmap to map a file, close() to unmap a file,
and either bigEndianIterator() or littleEndianIterator() to get a seekable
BufferIterator over the mapped data.| Constructor and Description |
|---|
MemoryMappedFile(long address,
long size)
Use this if you've called
mmap yourself. |
| Modifier and Type | Method and Description |
|---|---|
BufferIterator |
bigEndianIterator()
Returns a new iterator that treats the mapped data as big-endian.
|
void |
close()
Unmaps this memory-mapped file using munmap(2).
|
BufferIterator |
littleEndianIterator()
Returns a new iterator that treats the mapped data as little-endian.
|
static MemoryMappedFile |
mmapRO(String path)
Use this to mmap the whole file read-only.
|
long |
size()
Returns the size in bytes of the memory-mapped region.
|
public MemoryMappedFile(long address,
long size)
mmap yourself.public static MemoryMappedFile mmapRO(String path) throws ErrnoException
ErrnoExceptionpublic void close()
throws ErrnoException
close
yourself.
Calling this method invalidates any iterators over this MemoryMappedFile. It is an
error to use such an iterator after calling close.close in interface AutoCloseableErrnoExceptionpublic BufferIterator bigEndianIterator()
public BufferIterator littleEndianIterator()
public long size()