public class MappedRandomAccessFile extends Object
MappedByteBuffer
wrapped as a RandomAccessFile
Modifier and Type | Field and Description |
---|---|
private FileChannel |
channel |
private MappedByteBuffer |
mappedByteBuffer |
Constructor and Description |
---|
MappedRandomAccessFile(String filename,
String mode)
Constructs a new MappedRandomAccessFile instance
|
Modifier and Type | Method and Description |
---|---|
static boolean |
clean(ByteBuffer buffer)
invokes the clean method on the ByteBuffer's cleaner
|
void |
close() |
protected void |
finalize()
invokes the close method
|
FileChannel |
getChannel() |
long |
getFilePointer() |
private void |
init(FileChannel channel,
FileChannel.MapMode mapMode)
initializes the channel and mapped bytebuffer
|
long |
length() |
int |
read() |
int |
read(byte[] bytes,
int off,
int len) |
void |
seek(long pos) |
private MappedByteBuffer mappedByteBuffer
private FileChannel channel
public MappedRandomAccessFile(String filename, String mode) throws FileNotFoundException, IOException
filename
- Stringmode
- String r, w or rwFileNotFoundException
IOException
private void init(FileChannel channel, FileChannel.MapMode mapMode) throws IOException
channel
- FileChannelmapMode
- FileChannel.MapModeIOException
public FileChannel getChannel()
public int read()
RandomAccessFile.read()
public int read(byte[] bytes, int off, int len)
bytes
- byte[]off
- int offsetlen
- int lengthRandomAccessFile.read(byte[], int, int)
public long getFilePointer()
RandomAccessFile.getFilePointer()
public void seek(long pos)
pos
- long positionRandomAccessFile.seek(long)
public long length()
RandomAccessFile.length()
public void close() throws IOException
IOException
Cleans the mapped bytebuffer and closes the channel
protected void finalize() throws Throwable
finalize
in class Object
Throwable
Object.finalize()
public static boolean clean(ByteBuffer buffer)
buffer
- ByteBufferWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses