Dlaczego autor użył EntityUtils.consume (httpEntity) ;?
Natknąłem sięEntityUtils.consume(httpEntity);
i nie jestem pewien, co tak naprawdę robi.
Na przykład:
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();
}
Dlaczego autor to wprowadziłEntityUtils.consume(httpEntity);
kiedyfinally
blok zamknie połączenie i zajmie się garbage collectorhttpEntity
?