Handling a response body as a string

Handling a body response as a string can be accomplished using BodyHandlers.ofString(), as shown in the following snippet of code:

HttpResponse<String> responseOfString
= client.send(request, HttpResponse.BodyHandlers.ofString());

System.out.println("Status code: " + responseOfString.statusCode());
System.out.println("Body: " + responseOfString.body());

For specifying a charset, call ofString(String s, Charset charset).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9