Handling a response body as a file

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

HttpResponse<Path> responseOfFile = client.send(
request, HttpResponse.BodyHandlers.ofFile(
Path.of("response.json")));

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

For specifying the open options, call ofFile(Path file, OpenOption... openOptions).

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

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