Java examples for Network:Http
Make use of the HTTP/2 client API and make requests in either a synchronous or asynchronous manner.
try { HttpResponse resp = HttpRequest .create(new URI("http://www.apress.com/us/")).GET().response(); int statusCode = resp.statusCode(); String body = resp.body(HttpResponse.asString()); System.out.println("Status Code: " + statusCode); // Do something with body text } catch (URISyntaxException | IOException | InterruptedException ex) { ex.printStackTrace();; }