How do I do a HTTP GET in Java? [duplicate]
问题 This question already has an answer here: How to use java.net.URLConnection to fire and handle HTTP requests 11 answers How do I do a HTTP GET in Java? 回答1: If you want to stream any webpage, you can use the method below. import java.io.*; import java.net.*; public class c { public static String getHTML(String urlToRead) throws Exception { StringBuilder result = new StringBuilder(); URL url = new URL(urlToRead); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn