if (urls.size() > 0) {
HttpClient httpClient = null;
httpClient = SimpleHttpsTrustClientTemplate.createHttpClient();
HttpGet httpGet = new HttpGet();
HttpResponse response = null;
for (Iterator<String> iter = urls.iterator(); iter.hasNext();) {
httpGet.setURI(URI.create(iter.next()));
try {
response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_FOUND) {
iter.remove();
}
} catch (ClientProtocolException e) {
LOGGER.error(e);
} catch (IOException e) {
LOGGER.error(e);
} finally {
try {
if (response != null) {
response.getEntity().getContent().close();
}
} catch (IllegalStateException e) {
LOGGER.error(e);
} catch (IOException e) {
LOGGER.error(e);
}
}
}
}
转载于:https://blog.51cto.com/sun316737332/1602232