【发布时间】:2015-08-18 23:16:57
【问题描述】:
我正在做我的 API REST,我看到在很多示例中人们使用 EntityUtils.toString(response) 将他们的 response 从他们的 GET、POST、PUT 和 @ 转换为 String 987654328@ 方法。类似这样:
HttpGet method = new HttpGet(url);
method.setHeader("content-type", "application/json");
HttpResponse response = httpClient.execute(method);
String responseString = EntityUtils.toString(response.getEntity());
请避免对我说它给我一个字符串的答案
我知道它返回给我一个带有实体内容的String(在本例中为响应),但这是我的疑虑所在,因为我不确定这个String 返回的内容。我在官方文档中看到了。
读取实体的内容并将其作为字符串返回。
content-type 中返回的是String 吗?
相反,我通过我的方法获得的值是 String 中返回的值吗?
我认为这是第二个问题,但我对此并不安全。而且,如果是真的,这些值是如何存储到String 中的?它们是用逗号分隔还是一些特殊字符?
提前致谢!
【问题讨论】:
标签: android apache rest entity