Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/HTTP/Java/http-3.java
Normal file
19
Task/HTTP/Java/http-3.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
var request = HttpRequest.newBuilder(URI.create("https://www.rosettacode.org"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
HttpClient.newHttpClient()
|
||||
.sendAsync(request, HttpResponse.BodyHandlers.ofString(Charset.defaultCharset()))
|
||||
.thenApply(HttpResponse::body)
|
||||
.thenAccept(System.out::println)
|
||||
.join();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue