public class HttpClientUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(CloseableHttpResponse response)
无条件接近回应。
|
static void |
closeQuietly(HttpClient httpClient)
无条件关闭httpClient。
|
static void |
closeQuietly(HttpResponse response)
无条件接近回应。
|
public static void closeQuietly(HttpResponse response)
示例代码:
HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpGet);
} catch (Exception e) {
// error handling
} finally {
HttpClientUtils.closeQuietly(httpResponse);
}
response - 释放资源的HttpResponse可能为null或已经关闭。
public static void closeQuietly(CloseableHttpResponse response)
示例代码:
HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpGet);
} catch (Exception e) {
// error handling
} finally {
HttpClientUtils.closeQuietly(httpResponse);
}
response - 释放资源的HttpResponse可能为null或已经关闭。
public static void closeQuietly(HttpClient httpClient)
示例代码:
HttpClient httpClient = HttpClients.createDefault();
try {
httpClient.execute(request);
} catch (Exception e) {
// error handling
} finally {
HttpClientUtils.closeQuietly(httpClient);
}
httpClient - HttpClient关闭,可能为null或已经关闭。
Copyright © 1999–2017 The Apache Software Foundation. All rights reserved.