本文整理匯總了Java中org.apache.http.client.methods.HttpDelete.releaseConnection方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpDelete.releaseConnection方法的具體用法?Java HttpDelete.releaseConnection怎麽用?Java HttpDelete.releaseConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.client.methods.HttpDelete
的用法示例。
在下文中一共展示了HttpDelete.releaseConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteFile
import org.apache.http.client.methods.HttpDelete; //導入方法依賴的package包/類
public String deleteFile(String deleteURL) throws IllegalStateException {
HttpResponse response = null;
HttpDelete delete = new HttpDelete(deleteURL);
try {
response = httpClient.execute(delete);
String statusCode = String.valueOf(response.getStatusLine().getStatusCode());
if (statusCode.indexOf("20") == 0) {
HttpEntity entity = response.getEntity();
String contentType = entity.getContentType().getValue();
LOG.info("contentType=" + contentType);
return StrUtil.readStream(entity.getContent(), responseContextEncode);
} else if (statusCode.indexOf("40") == 0) {
LOG.error("Page: " + deleteURL + " no find");
return "Page no find";
} else {
LOG.error("返回狀態碼:[" + statusCode + "]");
return "返回狀態碼:[" + statusCode + "]";
}
} catch (Exception e) {
e.printStackTrace();
} finally {
delete.releaseConnection();
}
return null;
}