Anonymous user
HTTP: Difference between revisions
Updated the Java example to use the modern standard HTP Client API
m (→{{header|Phix}}: fixed libheader) |
(Updated the Java example to use the modern standard HTP Client API) |
||
Line 1,277:
=={{header|Java}}==
Using the standard [http://openjdk.java.net/groups/net/httpclient/ Java 11 HTTP Client]
<lang java5>import java.util.Scanner;▼
import java.net.URL; ▼
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.Charset;
public class Main {
public static void main(String[] args)
HttpClient.newHttpClient()
.sendAsync(request, HttpResponse.BodyHandlers.ofString(Charset.defaultCharset()))
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
}
}
|