Creating a body from a file can be accomplished using BodyPublishers.ofFile(), as shown in the following snippet of code:
HttpRequest requestBodyOfFile = HttpRequest.newBuilder()
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of("user.json")))
.uri(URI.create("https://reqres.in/api/users"))
.build();