From c85d3e2846bc2312d0b09e78c0cf58af92de4952 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Mon, 25 Apr 2022 18:03:53 +0000 Subject: [PATCH] Basic Client structure --- client.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 client.java diff --git a/client.java b/client.java new file mode 100644 index 0000000..77e5391 --- /dev/null +++ b/client.java @@ -0,0 +1,26 @@ +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.util.concurrent.CompletableFuture; +import java.net.http.HttpClient; + +public class client { + public static void main(String[] args) { + try { + HttpRequest req = HttpRequest.newBuilder(new URI("https://postman-echo.com/get")) + .version(HttpClient.Version.HTTP_2) + .GET().build(); + + HttpClient client = HttpClient.newBuilder().build(); + + HttpResponse response = client.send(req,BodyHandlers.ofString()); + + System.out.println(response.body()); + } catch (URISyntaxException | IOException | InterruptedException e) { + e.printStackTrace(); + } + } +}