为什么作者使用EntityUtils.consume(httpEntity);?
我遇到过,我不确定它到底做了什么。EntityUtils.consume(httpEntity);
例如:
try {
//... some code
HttpEntity httpEntity = httpResponse.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(http.Entity.getContent()));
String line;
while ((line = br.readLine())!= null) {
System.out.println(line);
}
EntityUtils.consume(httpEntity);
} catch (Exception e) {
//code
} finally {
httpClient.getConnectionManager().shutdown();
}
为什么作者在块将关闭连接和垃圾收集器将处理时放入?EntityUtils.consume(httpEntity);
finally
httpEntity