rabbit.httpio
Interface Transferable

All Known Subinterfaces:
ResourceSource
All Known Implementing Classes:
CacheResourceSource, FileResourceSource, RandomCacheResourceSource, WebConnectionResourceSource

public interface Transferable

The methods needed for fast transferTo.

Author:
Robert Olofsson

Method Summary
 long length()
          Get the length of the resource in bytes.
 long transferTo(long position, long count, WritableByteChannel target)
          Transfers bytes from this channel's file to the given writable byte channel.
 

Method Detail

length

long length()
Get the length of the resource in bytes.

Returns:
the size of the resource or -1 if unknown.

transferTo

long transferTo(long position,
                long count,
                WritableByteChannel target)
                throws IOException
Transfers bytes from this channel's file to the given writable byte channel.

Parameters:
position - The position within the file at which the transfer is to begin; must be non-negative
count - The maximum number of bytes to be transferred; must be non-negative
target - The target channel
Returns:
The number of bytes, possibly zero, that were actually transferred
Throws:
IOException
See Also:
transferTo