我想在JavaFX应用程序中使用Apache HttpClient组件,但它会挂起,并且在尝试执行时根本不做任何事情。
我正在使用IntelliJ,项目库中只有httpclient-4.5.1.jar和httpcore-4.4.3.jar。
非常感谢任何帮助。
我只是简单地实例化使用它的Class:
HttpDownloadUtility httpDownloadUtility = new HttpDownloadUtility();
httpDownloadUtility.httpDownloadFile(param);
这是班级:
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
public class HttpDownloadUtility {
public void httpDownloadFile(Job job) {
try {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpget = new HttpGet("https://www.google.com");
CloseableHttpResponse response = httpclient.execute(httpget);
response.close();
System.out.println("Ran");
} catch (Exception ex) {
}
}
}