📜  在线 java http 请求演示 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:36.903000             🧑  作者: Mango

代码示例1
public void get(String uri) throws Exception {
    HttpClient client = HttpClient.newHttpClient();
    HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(uri))
          .build();

    HttpResponse response =
          client.send(request, BodyHandlers.ofString());

    System.out.println(response.body());
}