import java.net.http.HttpResponse;
      import java.net.http.HttpRequest;
      import java.net.http.HttpClient;
      import java.net.URI,java.io.IOException;
      
      try {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create(yourUri)).build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      } catch (IOException e) {
        // I/O exception handling
      } catch (InterruptedException e) {
       // request interrupted
      }
      Java language logo

      HTTP get request

      http
      Java Public Recipes

      Make get request with the standard library

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.