나는 EntityUtils.consume(httpEntity);
을 만났습니다. 그리고 나는 그것이 정말로 무엇을하는지 확신하지 못합니다. 예를 들어저자가 EntityUtils.consume (httpEntity);을 사용하는 이유는 무엇입니까?
다음 finally
블록이 연결을 종료하고 가비지 컬렉터가 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();
}
?