com.google.appengine.api.files
Class BufferedFileReadChannelImpl

java.lang.Object
  extended by com.google.appengine.api.files.BufferedFileReadChannelImpl
All Implemented Interfaces:
FileReadChannel, java.io.Closeable, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel

public class BufferedFileReadChannelImpl
extends java.lang.Object
implements FileReadChannel

Wraps a FileReadChannel to provide buffering of reads.


Constructor Summary
BufferedFileReadChannelImpl(FileReadChannel readChannel, int bufferSize)
           
 
Method Summary
 void close()
          
 boolean isOpen()
          
 long position()
          Returns this channel's file position;
 FileReadChannel position(long newPosition)
          Sets this channel's file position.
 int read(java.nio.ByteBuffer dst)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedFileReadChannelImpl

public BufferedFileReadChannelImpl(FileReadChannel readChannel,
                                   int bufferSize)
Method Detail

read

public int read(java.nio.ByteBuffer dst)
         throws java.io.IOException
Specified by:
read in interface java.nio.channels.ReadableByteChannel
Throws:
java.io.IOException

isOpen

public boolean isOpen()

Specified by:
isOpen in interface java.nio.channels.Channel

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface java.nio.channels.Channel
Throws:
java.io.IOException

position

public long position()
              throws java.io.IOException
Description copied from interface: FileReadChannel
Returns this channel's file position;

Specified by:
position in interface FileReadChannel
Returns:
This channel's file position, a non-negative integer counting the number of bytes from the beginning of the file to the current position
Throws:
java.io.IOException - If any problem occurs

position

public FileReadChannel position(long newPosition)
                         throws java.io.IOException
Description copied from interface: FileReadChannel
Sets this channel's file position.

Setting the position to a value that is greater than the file's size will not result in an exception. A later attempt to read bytes at such a position will immediately return an end-of-file indication.

Specified by:
position in interface FileReadChannel
Parameters:
newPosition - The new position, a non-negative integer counting the number of bytes from the beginning of the file
Returns:
This channel
Throws:
java.io.IOException - If any other problem occurs