Created
September 28, 2018 05:28
-
-
Save cosminpopescu14/9c8b6de3deeb2ca51270f6902c1fddb4 to your computer and use it in GitHub Desktop.
java 11 features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse; | |
public class Main { | |
public static void main(String[] args) throws InterruptedException, IOException | |
{ | |
// write your code here | |
var request = HttpRequest.newBuilder() | |
.GET() | |
.uri(URI.create("https://http2.akamai.com/demo/h2_demo_frame.html")) | |
.build(); | |
var client = HttpClient.newHttpClient(); | |
client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) | |
.thenApply(response -> { | |
System.out.println(response.statusCode()); | |
return response; | |
}) | |
.thenApply(HttpResponse::body) | |
.thenAccept(System.out::println) | |
.join(); //don't forget it*/ | |
/*HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); | |
System.out.println(response.body());*/ | |
System.out.println(" ".isBlank()); | |
System.out.println("Cosmin ".repeat(2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment