0

我正在使用 Apache HTTP 客户端并尝试从响应中提取内容...

我在名为“响应”的 HTTP 响应对象中有响应。

现在,如何从 HTTPResponse 对象中提取以下内容??--

(1) 响应内容为 byte[] (2) 内容长度 (3) Mime 类型 (4) Charset

4

2 回答 2

1

你需要得到HttpEntity和做getContentLenght()getContentType();。这是apache教程

于 2012-01-29T12:24:37.697 回答
1
HttpEntity entity = response.getEntity();
InputStream instream = entity.getContent();
instream.read();

这是主要代码。您可以在以下位置查看示例:httpcomponents-client-4.1.3\examples\org\apache\http\examples\client

于 2012-03-02T02:11:12.910 回答