iitb.con.io
Interface IOAdapter

All Known Implementing Classes:
BufferedFileAdapter, FileAdapter, MemMapFileAdapter

public interface IOAdapter

Interface to handle IO operations with file.

See Also:
ByteBuffer

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.
 

Method Detail

close

void close()
           throws java.io.IOException
Closes the IO Adapter

Throws:
java.io.IOException - if file operation fails

getFileLength

long getFileLength()
Returns the length of the file

Returns:
file length

read

byte[] read(long location,
            int length)
            throws java.io.IOException
Reads the contents and return it as byte array.

Parameters:
location - location of the content in file
length - length of the content to read from the specified location
Returns:
contents in a byte array
Throws:
java.io.IOException

readFileAsBlocks

java.nio.ByteBuffer[] readFileAsBlocks()
                                       throws java.io.IOException
Reads the entire contents of the file as ByteBuffer array.
The contents as divided as block based on the block size value

Returns:
contents as ByteBuffer array
Throws:
java.io.IOException - if file operation fails

readIntoBuffer

java.nio.ByteBuffer readIntoBuffer(long location)
                                   throws java.io.IOException
Reads the contents into the temporary buffer and returns it as ByteBuffer

Parameters:
location - location to be read
Returns:
contents as ByteBuffer
Throws:
java.io.IOException - if file operation fails

write

void write(byte[] block,
           long location)
           throws java.io.IOException
Writes the contents to the specified location.

Parameters:
block - the content block as bytes
location - location to be written
Throws:
java.io.IOException - if file operation fails

write

void write(java.nio.ByteBuffer[] blocks,
           long location)
           throws java.io.IOException
Writes the contents provided as array to the specified location.

Parameters:
blocks - contents as array of blocks
location - location to be written
Throws:
java.io.IOException - if file operation fails

write

void write(java.nio.ByteBuffer block,
           long location)
           throws java.io.IOException
Writes the contents to the specified location.

Parameters:
block - the content block
location - location to be written
Throws:
java.io.IOException - if file operation fails