当我尝试执行“http://www.oracle.com”时出现运行时错误。它说,error java.net.UnknnownHostException:www.oracle.com
然后它列出了一大堆与Sockets,HttpURLConnection等有关的错误。它们都指向这个连接方法,特别是InputStream steam
行。
这是我的代码:
public void connect (String website) throws IOException {
URL u = new URL(website);
URLConnection conn = u.openConnection();
InputStream stream = conn.getInputStream();
Scanner input = new Scanner(stream);
input.useDelimiter("<a");
readWebsite(input);
}
答案 0 :(得分:0)
尝试通过IP地址连接:
URL u = new URL("http://23.56.70.140");