org.apache.http.entity
Class InputStreamEntityHC4
java.lang.Object
org.apache.http.entity.AbstractHttpEntityHC4
org.apache.http.entity.InputStreamEntityHC4
- All Implemented Interfaces:
- org.apache.http.HttpEntity
@NotThreadSafe
public class InputStreamEntityHC4
- extends AbstractHttpEntityHC4
A streamed, non-repeatable entity that obtains its content from
an InputStream.
- Since:
- 4.0
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InputStreamEntityHC4
public InputStreamEntityHC4(java.io.InputStream instream)
- Creates an entity with an unknown length.
Equivalent to
new InputStreamEntityHC4(instream, -1).
- Parameters:
instream - input stream
- Throws:
java.lang.IllegalArgumentException - if instream is null- Since:
- 4.3
InputStreamEntityHC4
public InputStreamEntityHC4(java.io.InputStream instream,
long length)
- Creates an entity with a specified content length.
- Parameters:
instream - input streamlength - of the input stream, -1 if unknown
- Throws:
java.lang.IllegalArgumentException - if instream is null
InputStreamEntityHC4
public InputStreamEntityHC4(java.io.InputStream instream,
ContentType contentType)
- Creates an entity with a content type and unknown length.
Equivalent to
new InputStreamEntityHC4(instream, -1, contentType).
- Parameters:
instream - input streamcontentType - content type
- Throws:
java.lang.IllegalArgumentException - if instream is null- Since:
- 4.3
InputStreamEntityHC4
public InputStreamEntityHC4(java.io.InputStream instream,
long length,
ContentType contentType)
- Parameters:
instream - input streamlength - of the input stream, -1 if unknowncontentType - for specifying the Content-Type header, may be null
- Throws:
java.lang.IllegalArgumentException - if instream is null- Since:
- 4.2
isRepeatable
public boolean isRepeatable()
getContentLength
public long getContentLength()
- Returns:
- the content length or
-1 if unknown
getContent
public java.io.InputStream getContent()
throws java.io.IOException
- Throws:
java.io.IOException
writeTo
public void writeTo(java.io.OutputStream outstream)
throws java.io.IOException
- Writes bytes from the
InputStream this entity was constructed
with to an OutputStream. The content length
determines how many bytes are written. If the length is unknown (-1), the
stream will be completely consumed (to the end of the stream).
- Throws:
java.io.IOException
isStreaming
public boolean isStreaming()