public static void main() throws IOException { URL url = new URL("https://www.baidu.com/img/bdlogo.png"); Object obj = url.getContent(); System.out.println(obj.getClass().getName()); }
public static void main(String[] args) throws IOException { String urls = "https://www.baidu.com"; URL url = new URL(urls); URLConnection uc = url.openConnection(); InputStream is = uc.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); } }