import com.ning.http.client.*;
public class AsyncHttpClientExample {
public static void main(String[] args) throws Exception {
AsyncHttpClient client = new AsyncHttpClient();
String url = "http://api.example.com/data";
RequestBuilder builder = new RequestBuilder("GET").setUrl(url);
ListenableFuture<Response> listenableFuture = client.executeRequest(builder.build());
listenableFuture.addListener(() -> {
try {
Response response = listenableFuture.get();
System.out.println("Response status code: " + response.getStatusCode());
System.out.println("Response body: " + response.getResponseBody());
} catch (Exception e) {
e.printStackTrace();
} finally {
client.close();
}
}, null);
}
}