class UriBuilder {
void build() throws MalformedURLException {
Map<String, ? extends Serializable> params = Map.of("user_id", 123456789);
URI uri = UriBuilder
.fromUri("http://localhost:5040")
.segment("users", "{user_id}", "books")
.queryParam("author", "balzac")
.buildFromMap(params);
URL url = uri.toURL();
//will display: http://localhost:5040/users/123456789/books?author=balzac
System.out.println(url.toString());
}
}