com.ning.http.client.generators
Class FileBodyGenerator.FileBody

java.lang.Object
  extended by com.ning.http.client.generators.FileBodyGenerator.FileBody
All Implemented Interfaces:
Body, RandomAccessBody
Enclosing class:
FileBodyGenerator

protected static class FileBodyGenerator.FileBody
extends Object
implements RandomAccessBody


Constructor Summary
FileBodyGenerator.FileBody(File file)
           
FileBodyGenerator.FileBody(File file, long regionSeek, long regionLength)
           
 
Method Summary
 void close()
          Releases any resources associated with this body.
 long getContentLength()
          Gets the length of the body.
 long read(ByteBuffer buffer)
          Reads the next chunk of bytes from the body.
 long transferTo(long position, long count, WritableByteChannel target)
          Transfers the specified chunk of bytes from this body to the specified channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBodyGenerator.FileBody

public FileBodyGenerator.FileBody(File file)
                           throws IOException
Throws:
IOException

FileBodyGenerator.FileBody

public FileBodyGenerator.FileBody(File file,
                                  long regionSeek,
                                  long regionLength)
                           throws IOException
Throws:
IOException
Method Detail

getContentLength

public long getContentLength()
Description copied from interface: Body
Gets the length of the body.

Specified by:
getContentLength in interface Body
Returns:
The length of the body in bytes, or negative if unknown.

read

public long read(ByteBuffer buffer)
          throws IOException
Description copied from interface: Body
Reads the next chunk of bytes from the body.

Specified by:
read in interface Body
Parameters:
buffer - The buffer to store the chunk in, must not be null.
Returns:
The non-negative number of bytes actually read or -1 if the body has been read completely.
Throws:
IOException - If the chunk could not be read.

transferTo

public long transferTo(long position,
                       long count,
                       WritableByteChannel target)
                throws IOException
Description copied from interface: RandomAccessBody
Transfers the specified chunk of bytes from this body to the specified channel.

Specified by:
transferTo in interface RandomAccessBody
Parameters:
position - The zero-based byte index from which to start the transfer, must not be negative.
count - The maximum number of bytes to transfer, must not be negative.
target - The destination channel to transfer the body chunk to, must not be null.
Returns:
The non-negative number of bytes actually transferred.
Throws:
IOException - If the body chunk could not be transferred.

close

public void close()
           throws IOException
Description copied from interface: Body
Releases any resources associated with this body.

Specified by:
close in interface Body
Throws:
IOException


Copyright © 2011. All Rights Reserved.