try {
URL u = new URL("http://[::1]/index.php");
InputStream in = u.openStream();
int b;
while ((b = in.read()) != -1) {
System.out.write(b);
}
}
catch (MalformedURLException e) {System.out.println(e);}
catch (IOException e) {System.out.println(e);}
返回
运行:java.net.ConnectException:连接被拒绝:连接 BUILD SUCCESSFUL(总时间:1 秒)
为什么会抛出错误?如何解决?