Package org.apache.http.entity
Class FileEntity
java.lang.Object
org.apache.http.entity.AbstractHttpEntity
org.apache.http.entity.FileEntity
- All Implemented Interfaces:
Cloneable,HttpEntity
public class FileEntity extends AbstractHttpEntity implements Cloneable
An entity whose content is retrieved from a file.
- Since:
- 4.0
- Version:
- $Revision: 604625 $
- Author:
- Oleg Kalnichevski
-
Field Summary
Fields inherited from class org.apache.http.entity.AbstractHttpEntity
chunked, contentEncoding, contentType -
Constructor Summary
Constructors Constructor Description FileEntity(File file, String contentType) -
Method Summary
Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.InputStreamgetContent()Creates a new InputStream object of the entity.longgetContentLength()Tells the length of the content, if known.booleanisRepeatable()Tells if the entity is capable to produce its data more than once.booleanisStreaming()Tells that this entity is not streaming.voidwriteTo(OutputStream outstream)Writes the entity content to the output stream.Methods inherited from class org.apache.http.entity.AbstractHttpEntity
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType
-
Field Details
-
file
-
-
Constructor Details
-
FileEntity
-
-
Method Details
-
isRepeatable
public boolean isRepeatable()Description copied from interface:HttpEntityTells if the entity is capable to produce its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.- Specified by:
isRepeatablein interfaceHttpEntity- Returns:
- true if the entity is repeatable, false otherwise.
-
getContentLength
public long getContentLength()Description copied from interface:HttpEntityTells the length of the content, if known.- Specified by:
getContentLengthin interfaceHttpEntity- Returns:
- the number of bytes of the content, or
a negative number if unknown. If the content length is known
but exceeds
Long.MAX_VALUE, a negative number is returned.
-
getContent
Description copied from interface:HttpEntityCreates a new InputStream object of the entity. It is a programming error to return the same InputStream object more than once. Entities that are notrepeatablewill throw an exception if this method is called multiple times.- Specified by:
getContentin interfaceHttpEntity- Returns:
- a new input stream that returns the entity data.
- Throws:
IOException- if the stream could not be created
-
writeTo
Description copied from interface:HttpEntityWrites the entity content to the output stream.- Specified by:
writeToin interfaceHttpEntity- Parameters:
outstream- the output stream to write entity content to- Throws:
IOException- if an I/O error occurs
-
isStreaming
public boolean isStreaming()Tells that this entity is not streaming.- Specified by:
isStreamingin interfaceHttpEntity- Returns:
false
-
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects.- Overrides:
clonein classObject- Returns:
- a copy of this object.
- Throws:
CloneNotSupportedException- if this object's class does not implement theCloneableinterface.
-