import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
public class URLTest{
public static void main(String[] args){
//設置系統網絡代理服務器
//System.setProperty("http.proxyHost","192.168.1.1");
//System.setProperty("http.proxyHost","80");
try{
//實例化一個URL
URL tirc = new URL("http://www.google.cn/");
//得到遠程主機網頁的字符流信息並封裝給BufferedReader
BufferedReader br = new BufferedReader(new InputStreamReader(tirc.openStream()));
//將信息輸出到屏幕上
while(br.readLine()!= null){
String s = br.readLine();
System.out.println(s);
}
br.close();
}
catch(MalformedURLException e){
System.out.println(e);
}
catch(IOException e){
System.out.println(e);
}
}
}