转载自:http://blog.youkuaiyun.com/f1313131/article/details/53794819
Log.d("xxgetLabModelS", response.body().string());
JSONObject json = new JSONObject(response.body().string());
因为调用了response.body().string()两次;
导致第二次会出现这种错误。
删除一次即可。
改为:
String respStr = response.body().string();
Log.d("xxgetLabModelS", respStr);
JSONObject json = new JSONObject(respStr);
在这里找到类似情况:
http://stackoverflow.com/questions/33089581/what-is-the-reason-of-this-error-Java-io-ioexception-content-length-and-stream
本文介绍了一个常见的编程问题:重复调用response.body().string()导致的异常,并提供了解决方案,即将响应体字符串赋值给一个变量再进行使用。
1784

被折叠的 条评论
为什么被折叠?



