protected static class

FileBodyGenerator.FileBody

extends Object
implements RandomAccessBody
java.lang.Object
   ↳ com.ning.http.client.generators.FileBodyGenerator.FileBody

Summary

Public Constructors
FileBodyGenerator.FileBody(File file)
FileBodyGenerator.FileBody(File file, long regionSeek, long regionLength)
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.ning.http.client.Body
From interface com.ning.http.client.RandomAccessBody

Public Constructors

public FileBodyGenerator.FileBody (File file)

Throws
IOException

public FileBodyGenerator.FileBody (File file, long regionSeek, long regionLength)

Throws
IOException

Public Methods

public void close ()

Releases any resources associated with this body.

Throws
IOException

public long getContentLength ()

Gets the length of the body.

Returns
  • The length of the body in bytes, or negative if unknown.

public long read (ByteBuffer buffer)

Reads the next chunk of bytes from the 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

public long transferTo (long position, long count, WritableByteChannel target)

Transfers the specified chunk of bytes from this body to the specified channel.

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