In order to get information about the response, we can rely on the methods from the HttpResponse class. The names of these methods are very intuitive; therefore, the following snippet of code is self-explanatory:
...
HttpResponse<String> response
= client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Version: " + response.version());
System.out.println(" URI: " + response.uri());
System.out.println(" Status code: " + response.statusCode());
System.out.println(" Headers: " + response.headers());
System.out.println(" Body: " + response.body());
Consider exploring the documentation to find more useful methods.