我正在研究HttpClient
Java 11 的新功能,但工作不正常。当我尝试从网站打印正文时,该body()
方法打印空行:
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());
为什么response.body()
不打印正文中的内容?