|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectiitb.con.io.MemMapFileAdapter
public class MemMapFileAdapter
MemMapFileAdapter uses MappedByteBuffer as the buffer which maps the file contents to memory for the read and write file operations. It uses RandomAccessFile as the file operation mode.
Constructor Summary | |
---|---|
MemMapFileAdapter(java.lang.String name,
java.lang.String mode)
Initializes the MemMapFileAdapter with file name and mode. |
Method Summary | |
---|---|
void |
close()
Closes the IO Adapter |
long |
getFileLength()
Returns the length of the file |
byte[] |
read(long location,
int length)
Reads the contents and return it as byte array. |
java.nio.ByteBuffer[] |
readFileAsBlocks()
Reads the entire contents of the file as ByteBuffer array. The contents as divided as block based on the block size value |
java.nio.ByteBuffer |
readIntoBuffer(long location)
Reads the contents into the temporary buffer and returns it as ByteBuffer |
void |
write(byte[] block,
long location)
Writes the contents to the specified location. |
void |
write(java.nio.ByteBuffer[] blocks,
long location)
Writes the contents provided as array to the specified location. |
void |
write(java.nio.ByteBuffer block,
long location)
Writes the contents to the specified location. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MemMapFileAdapter(java.lang.String name, java.lang.String mode) throws java.io.FileNotFoundException, java.io.IOException
name
- file namemode
- opening mode (r, rw)
java.io.FileNotFoundException
- if file does not found
java.io.IOException
Method Detail |
---|
public void close() throws java.io.IOException
close
in interface IOAdapter
java.io.IOException
- if file operation failspublic long getFileLength()
getFileLength
in interface IOAdapter
public byte[] read(long location, int length) throws java.io.IOException
read
in interface IOAdapter
location
- location of the content in filelength
- length of the content to read from the specified location
java.io.IOException
public java.nio.ByteBuffer[] readFileAsBlocks() throws java.io.IOException
readFileAsBlocks
in interface IOAdapter
java.io.IOException
- if file operation failspublic java.nio.ByteBuffer readIntoBuffer(long location) throws java.io.IOException
readIntoBuffer
in interface IOAdapter
location
- location to be read
java.io.IOException
- if file operation failspublic void write(byte[] block, long location) throws java.io.IOException
write
in interface IOAdapter
block
- the content block as byteslocation
- location to be written
java.io.IOException
- if file operation failspublic void write(java.nio.ByteBuffer[] blocks, long location) throws java.io.IOException
write
in interface IOAdapter
blocks
- contents as array of blockslocation
- location to be written
java.io.IOException
- if file operation failspublic void write(java.nio.ByteBuffer block, long location) throws java.io.IOException
write
in interface IOAdapter
block
- the content blocklocation
- location to be written
java.io.IOException
- if file operation fails
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |