I'm studying the new HttpClient
from Java 11 and is not working properly. When I try to print the body from a website the body()
method print blank lines:
var httpClient = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("http://iteratorlearning.com")).build();
HttpResponse<String> response = httpClient.send(request,BodyHandlers.ofString());
System.out.println("Printing Body : " + response.body());
Why response.body()
doesn't print the content from the body?