Created
August 2, 2019 14:35
-
-
Save NikolayGorshkov/fcd3c0700a15b6b36ec74b3df55e0343 to your computer and use it in GitHub Desktop.
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
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpClient.Redirect; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse.BodyHandlers; | |
public class HttpClientExample { | |
public static void main(String[] args) throws Exception { | |
String response = | |
HttpClient.newBuilder() | |
.followRedirects(Redirect.NORMAL) | |
.build() | |
.send( | |
HttpRequest.newBuilder() | |
.GET().uri(new URI("https://google.com/")) | |
.build(), | |
BodyHandlers.ofString()) | |
.body(); | |
System.out.println(response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment