作者在 2010-05-24 09:24:44 发布以下内容
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
public class URLReader{
public static void main(String args[]){
try{
URL tirc = new URL("http://www.google.cn/");
BufferedReader in = new BufferedReader(new
InputStreamReader(tirc.openStream()));
String s;
while((s = in.readLine())!=null)
System.out.println(s);
in.close();
}catch(MalformedURLException e) {
System.out.println(e);
}catch(IOException e){
System.out.println(e);
}
}
}
import java.util.Scanner;
import java.net.URL;
import java.io.IOException;
import java.net.MalformedURLException;
public class URLReader{
public static void main(String args[]){
try{
URL tirc = new URL("http://www.google.cn/");
Scanner scan = new Scanner(tirc.openStream());
while(scan.hasNext()){
System.out.println(scan.next());
}
}catch(IOException e){
System.out.println(e);
}
}
}
import java.net.URL;
import java.io.IOException;
import java.net.MalformedURLException;
public class URLReader{
public static void main(String args[]){
try{
URL tirc = new URL("http://www.google.cn/");
Scanner scan = new Scanner(tirc.openStream());
while(scan.hasNext()){
System.out.println(scan.next());
}
}catch(IOException e){
System.out.println(e);
}
}
}