public final class EntityUtils extends Object
HttpEntitys.| Modifier and Type | Method and Description |
|---|---|
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.
|
public static void consumeQuietly(HttpEntity entity)
entity - public static void consume(HttpEntity entity) throws IOException
entity - IOException - if an error occurs reading the input streampublic static byte[] toByteArray(HttpEntity entity) throws IOException
entity - HttpEntity.getContent() is null.IOException - if an error occurs reading the input streamIllegalArgumentException - 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 nullParseException - if header elements cannot be parsedIllegalArgumentException - if entity is null@Deprecated public static String getContentMimeType(HttpEntity entity) throws ParseException
ContentType.getOrDefault(HttpEntity)entity - must not be nullParseException - if header elements cannot be parsedIllegalArgumentException - 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 entityHttpEntity.getContent() is null.ParseException - if header elements cannot be parsedIllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEIOException - if an error occurs reading the input streampublic 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 entityHttpEntity.getContent() is null.ParseException - if header elements cannot be parsedIllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEIOException - if an error occurs reading the input streampublic static String toString(HttpEntity entity) throws IOException, ParseException
entity - ParseException - if header elements cannot be parsedIllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEIOException - if an error occurs reading the input streamCopyright © 2005–2013 The Apache Software Foundation. All rights reserved.