Zest.

Java: HTTP GET request

A short, tested Java example for http get request. Copy it and adjust the names and paths for your project.

Java
var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.example.com/items")).build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());

Find it in Zest

Search for “java http get request” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Java examples

All Java examples