Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public CompletableFuture<String> getFoodAsync(HttpClient client, HttpRequest request) {
  2. return client.sendAsync(request, BodyHandlers.ofString()).thenApply(HttpResponse::body);
  3. }
  4. .....
  5.  
  6. URI uri = new URI(totalPath);
  7. HttpRequest request = HttpRequest.newBuilder(uri).build();
  8.  
  9. HttpClient client = HttpClient.newHttpClient();
  10.  
  11. var rand = new randomTest();
  12.  
  13. CompletableFuture<String> foodInfo = rand.getFoodAsync(client, request);
  14. foodInfo.join();
  15.  
  16. String json = foodInfo.get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement