相关疑难解决方法(0)

EntityUtils.toString(response) 究竟返回什么?

我做我的REST API,我看到了很多的例子人用EntityUtils.toString(response)得到他们response进入String他们的GETPOSTPUTDELETE方法。与此类似:

HttpGet method = new HttpGet(url);
method.setHeader("content-type", "application/json");
HttpResponse response = httpClient.execute(method);
String responseString = EntityUtils.toString(response.getEntity());
Run Code Online (Sandbox Code Playgroud)

请避免对我说它给我一个字符串的答案

我知道它返回给我一个String实体的内容(在这种情况下是响应),但这是我怀疑的地方,因为我对String返回的内容不放心。我在官方文档中看到了。

读取实体的内容并将其作为字符串返回。

https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/util/EntityUtils.html#toString(org.apache.http.HttpEntity,java.lang.String)

它是content-type什么在返回String

相反,我通过我的方法获得的值是在String?

我认为这是第二个问题,但我对此并不安全。而且,在这种情况下,这些值如何存储到String? 它们是由逗号或某些特殊字符分隔的吗?

提前致谢!

apache rest android entity

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

apache ×1

entity ×1

rest ×1