我正在尝试用org.apache.http.client记录一篇文章的正文。我使用的是Scalatra版本2.4.0.RC3和ScalaVersion2.11.7。我的响应是一个400坏的请求,我需要得到消息提供的响应主体。
以下是我的当前代码:
val response = client.execute(post)
println(response)
println(response.getEntity().getContent())response.getEntity().getContent()打印:
java.io.ByteArrayInputStream@1q232e4e我需要从这个ByteArrayInputStream中得到实际的字符串。
发布于 2015-11-13 16:16:38
您可以在同一个库中使用EntityUtils:
import org.apache.http.util.EntityUtils;
println(EntityUtils.toString(response.getEntity()));https://stackoverflow.com/questions/33697065
复制相似问题