1. Apache HttpClient 2. OkHttp import org.asynchttpclient.AsyncHttpClient; import org.asynchttpclient.BoundRequestBuilder; import org.asynchttpclient.DefaultAsyncHttpClient; import org.asynchttpclient.Response; public class AHCClientExample { public static void main(String[] args) throws Exception { AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient(); BoundRequestBuilder requestBuilder = asyncHttpClient.prepareGet("https://api.example.com"); Response response = requestBuilder.execute().get(); System.out.println("Response code: " + response.getStatusCode()); System.out.println("Response body: " + response.getResponseBody()); asyncHttpClient.close(); } }


上一篇:
下一篇:
切换中文