|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.util.EntityUtils
public final class EntityUtils
Static helpers for dealing with HttpEntity
s.
Method Summary | |
---|---|
static void |
consume(HttpEntity entity)
Ensures that the entity content is fully consumed and the content stream, if exists, is closed. |
static void |
consumeQuietly(HttpEntity entity)
Ensures that the entity content is fully consumed and the content stream, if exists, is closed. |
static String |
getContentCharSet(HttpEntity entity)
Deprecated. (4.1.3) use ContentType.getOrDefault(HttpEntity) |
static String |
getContentMimeType(HttpEntity entity)
Deprecated. (4.1.3) use ContentType.getOrDefault(HttpEntity) |
static byte[] |
toByteArray(HttpEntity entity)
Read the contents of an entity and return it as a byte array. |
static String |
toString(HttpEntity entity)
Read the contents of an entity and return it as a String. |
static String |
toString(HttpEntity entity,
Charset defaultCharset)
Get the entity content as a String, using the provided default character set if none is found in the entity. |
static String |
toString(HttpEntity entity,
String defaultCharset)
Get the entity content as a String, using the provided default character set if none is found in the entity. |
static void |
updateEntity(HttpResponse response,
HttpEntity entity)
Updates an entity in a response by first consuming an existing entity, then setting the new one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void consumeQuietly(HttpEntity entity)
entity
- the entity to consume.public static void consume(HttpEntity entity) throws IOException
entity
- the entity to consume.
IOException
- if an error occurs reading the input streampublic static void updateEntity(HttpResponse response, HttpEntity entity) throws IOException
response
- the response with an entity to update; must not be null.entity
- the entity to set in the response.
IOException
- if an error occurs while reading the input stream on the existing
entity.
IllegalArgumentException
- if response is null.public static byte[] toByteArray(HttpEntity entity) throws IOException
entity
- the entity to read from=
HttpEntity.getContent()
is null.
IOException
- if an error occurs reading the input stream
IllegalArgumentException
- if entity is null or if content length > Integer.MAX_VALUE@Deprecated public static String getContentCharSet(HttpEntity entity) throws ParseException
ContentType.getOrDefault(HttpEntity)
entity
- must not be null
ParseException
- if header elements cannot be parsed
IllegalArgumentException
- if entity is null@Deprecated public static String getContentMimeType(HttpEntity entity) throws ParseException
ContentType.getOrDefault(HttpEntity)
entity
- must not be null
ParseException
- if header elements cannot be parsed
IllegalArgumentException
- if entity is nullpublic static String toString(HttpEntity entity, Charset defaultCharset) throws IOException, ParseException
entity
- must not be nulldefaultCharset
- character set to be applied if none found in the entity,
or if the entity provided charset is invalid or not available.
HttpEntity.getContent()
is null.
ParseException
- if header elements cannot be parsed
IllegalArgumentException
- if entity is null or if content length > Integer.MAX_VALUE
IOException
- if an error occurs reading the input stream
UnsupportedCharsetException
- Thrown when the named entity's charset is not available in
this instance of the Java virtual machine and no defaultCharset is provided.public static String toString(HttpEntity entity, String defaultCharset) throws IOException, ParseException
entity
- must not be nulldefaultCharset
- character set to be applied if none found in the entity
HttpEntity.getContent()
is null.
ParseException
- if header elements cannot be parsed
IllegalArgumentException
- if entity is null or if content length > Integer.MAX_VALUE
IOException
- if an error occurs reading the input stream
UnsupportedCharsetException
- Thrown when the named charset is not available in
this instance of the Java virtual machinepublic static String toString(HttpEntity entity) throws IOException, ParseException
entity
- the entity to convert to a string; must not be null
ParseException
- if header elements cannot be parsed
IllegalArgumentException
- if entity is null or if content length > Integer.MAX_VALUE
IOException
- if an error occurs reading the input stream
UnsupportedCharsetException
- Thrown when the named charset is not available in
this instance of the Java virtual machine
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |