0
在我的程序中,我正在調用EntityUtils.consume(httpResponse.getEntity())。這是在代碼中拋出一個IOException,而對EntityUtils.toString(httpResponse.getEntity())的調用完全正常。任何想法可能是什麼問題?或者有什麼建議來解決IOException?EntityUtils .consume返回IOException
if(status >= 200 && status < 300) {
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
if(httpEntity.getContentLength() > Constants.HTTP.MAX_APP_CONTENT_LENGTH) {
throw new IllegalArgumentException("HTTP entity too large.");
}
result = EntityUtils.toString(httpEntity,"UTF-8");
EntityUtils.consume(httpEntity);
}
}