我正在尝试使用URL读取HTML文件。但是要获得超时的例外。
源代码:
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
System.setProperty("java.net.useSystemProxies","true");
URL oracle = new URL("http://www.oracle.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
答案 0 :(得分:0)
此代码适用于我,请检查您的互联网连接..