Handling a response body as a stream of strings

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

HttpResponse<Stream<String>> responseOfLines = client.send(
request, HttpResponse.BodyHandlers.ofLines());

System.out.println("Status code: " + responseOfLines.statusCode());
System.out.println("Body: "
+ responseOfLines.body().collect(toList()));
..................Content has been hidden....................

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