public class

NFileEntity

extends AbstractHttpEntity
implements ProducingNHttpEntity
java.lang.Object
   ↳ org.apache.http.entity.AbstractHttpEntity
     ↳ org.apache.http.nio.entity.NFileEntity

Class Overview

A self contained, repeatable non-blocking entity that retrieves its content from a file. This class is mostly used to stream large files of different types, so one needs to supply the content type of the file to make sure the content can be correctly recognized and processed by the recipient.

Summary

[Expand]
Inherited Fields
From class org.apache.http.entity.AbstractHttpEntity
Public Constructors
NFileEntity(File file, String contentType, boolean useFileChannels)
Creates new instance of NFileEntity from the given source File with the given content type.
NFileEntity(File file, String contentType)
Public Methods
void finish()
Notification that any resources allocated for writing can be released.
InputStream getContent()
long getContentLength()
boolean isRepeatable()
boolean isStreaming()
void produceContent(ContentEncoder encoder, IOControl ioctrl)
Notification that content should be written to the encoder.
void writeTo(OutputStream outstream)
[Expand]
Inherited Methods
From class org.apache.http.entity.AbstractHttpEntity
From class java.lang.Object
From interface org.apache.http.HttpEntity
From interface org.apache.http.nio.entity.ProducingNHttpEntity

Public Constructors

public NFileEntity (File file, String contentType, boolean useFileChannels)

Creates new instance of NFileEntity from the given source File with the given content type. If useFileChannels is set to true, the entity will try to use FileContentEncoder interface to stream file content directly from the file channel.

Parameters
file the source file.
contentType the content type of the file.
useFileChannels flag whether the direct transfer from the file channel should be attempted.

public NFileEntity (File file, String contentType)

Public Methods

public void finish ()

Notification that any resources allocated for writing can be released.

public InputStream getContent ()

Throws
IOException

public long getContentLength ()

public boolean isRepeatable ()

public boolean isStreaming ()

public void produceContent (ContentEncoder encoder, IOControl ioctrl)

Notification that content should be written to the encoder. IOControl instance passed as a parameter to the method can be used to suspend output events if the entity is temporarily unable to produce more content.

When all content is finished, this MUST call complete(). Failure to do so could result in the entity never being written.

Parameters
encoder content encoder.
ioctrl I/O control of the underlying connection.
Throws
IOException

public void writeTo (OutputStream outstream)

Throws
IOException