开发简洁的HTTP客户端
import java.io.IOException;/*时代Java 提供*/ import java.net.URI; import java.net.URISyntaxException; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import static java.net.http.HttpResponse.asFile; import static java.net.http.HttpResponse.asString; import static java.net.http.HttpResponse.ignoreBody; import java.nio.file.Path; import java.nio.file.Paths; import static java.util.UUID.fromString; import java.util.logging.Level; import java.util.logging.Logger;/*n o w j a v a . c o m 提 供*/ public class Main { public static void main(String[] args) { HttpResponse r1; try { r1 = HttpRequest.create(new URI("http://nowjava.com/")) .GET() .response(); int responseCode = r1.statusCode(); if(responseCode == 200){ System.out.println(r1.body(asStri