【发布时间】:2017-07-19 18:41:42
【问题描述】:
我们如何退出 HttpClient?没有找到方法。
HttpClient Client = new DefaultHttpClient();
String userpass = usr + ":" + pwd;
HttpPost httpGet = new HttpPost(dataimport_cmd);
String encoding = DatatypeConverter.printBase64Binary(userpass.getBytes("UTF-8"));
httpGet.setHeader("Authorization", "Basic " + encoding);
Client.execute(httpGet);
我尝试将执行封闭到一个可关闭的httpresponse,但它没有从类中退出。
CloseableHttpResponse response = (CloseableHttpResponse)
Client.execute(httpGet);
response.close();
我也尝试过使用 return 来退出课程。
返回;
【问题讨论】:
-
为什么要使用已弃用的类?对于已弃用的问题,您不会找到太多帮助
-
嗯。通常我正在使用的 IDE 会显示它。让我检查一下较新的课程
标签: java http-post httpclient