import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.Socket; import java.net.URL; import java.util.Scanner; public class UrlTest { public static void main(String[] args) throws IOException{ URL url = new URL("http://www.baidu.com/"); InputStream in = url.openStream(); Scanner s = new Scanner(in); while(s.hasNextLine()) System.out.println(s.nextLine()); } }