java.io.Closeable, java.lang.AutoCloseable, org.apache.http.HttpEntity, HttpAsyncContentProducer, ProducingNHttpEntitypublic class NFileEntity extends org.apache.http.entity.AbstractHttpEntity implements HttpAsyncContentProducer, ProducingNHttpEntity
| Constructor | Description |
|---|---|
NFileEntity(java.io.File file) |
|
NFileEntity(java.io.File file,
java.lang.String contentType) |
Deprecated.
(4.2) use
NFileEntity(File, ContentType) |
NFileEntity(java.io.File file,
java.lang.String contentType,
boolean useFileChannels) |
Deprecated.
(4.2) use
NFileEntity(File, ContentType, boolean) |
NFileEntity(java.io.File file,
org.apache.http.entity.ContentType contentType) |
Creates new instance of NFileEntity from the given source
File
with the given content type. |
NFileEntity(java.io.File file,
org.apache.http.entity.ContentType contentType,
boolean useFileChannels) |
Creates new instance of NFileEntity from the given source
File
with the given content type. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
void |
finish() |
Deprecated.
(4.2) use
close() |
java.io.InputStream |
getContent() |
|
long |
getContentLength() |
|
boolean |
isRepeatable() |
Determines whether or not this producer is capable of producing
its content more than once.
|
boolean |
isStreaming() |
|
void |
produceContent(ContentEncoder encoder,
IOControl ioctrl) |
Invoked to write out a chunk of content to the
ContentEncoder. |
void |
writeTo(java.io.OutputStream outstream) |
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType, toStringpublic NFileEntity(java.io.File file,
org.apache.http.entity.ContentType contentType,
boolean useFileChannels)
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.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(java.io.File file)
public NFileEntity(java.io.File file,
org.apache.http.entity.ContentType contentType)
File
with the given content type.file - the source file.contentType - the content type of the file.@Deprecated
public NFileEntity(java.io.File file,
java.lang.String contentType,
boolean useFileChannels)
NFileEntity(File, ContentType, boolean)@Deprecated
public NFileEntity(java.io.File file,
java.lang.String contentType)
NFileEntity(File, ContentType)public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOException@Deprecated
public void finish()
throws java.io.IOException
close()finish in interface ProducingNHttpEntityjava.io.IOExceptionpublic long getContentLength()
getContentLength in interface org.apache.http.HttpEntitypublic boolean isRepeatable()
HttpAsyncContentProducerisRepeatable in interface HttpAsyncContentProducerisRepeatable in interface org.apache.http.HttpEntitypublic void produceContent(ContentEncoder encoder, IOControl ioctrl) throws java.io.IOException
HttpAsyncContentProducerContentEncoder.
The IOControl interface can be used to suspend output event
notifications if the entity is temporarily unable to produce more content.
When all content is finished, the producer MUST call
ContentEncoder.complete(). Failure to do so may cause the entity
to be incorrectly delimited.
Please note that the ContentEncoder object is not thread-safe and
should only be used within the context of this method call.
The IOControl object can be shared and used on other thread
to resume output event notifications when more content is made available.
produceContent in interface HttpAsyncContentProducerproduceContent in interface ProducingNHttpEntityencoder - content encoder.ioctrl - I/O control of the underlying connection.java.io.IOExceptionpublic boolean isStreaming()
isStreaming in interface org.apache.http.HttpEntitypublic java.io.InputStream getContent()
throws java.io.IOException
getContent in interface org.apache.http.HttpEntityjava.io.IOExceptionpublic void writeTo(java.io.OutputStream outstream)
throws java.io.IOException
writeTo in interface org.apache.http.HttpEntityjava.io.IOException