java 读取网页内容的实例详解
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
public class loadurl {
public static void main(String args[]) {
String a = null;
try {
String url = "(这里替换成任意网页的网址)";
BufferedReader in = new BufferedReader(new InputStreamReader(
new URL(url).openConnection().getInputStream(), "GB2312"));//GB2312可以根据需要替换成要读取网页的编码
while ((a = in.readLine()) != null) {
System.out.println(a);
}
} catch (MalformedURLException e) {
} catch (IOException e) {
}
}
}