我正在尝试使用“isReachable”方法检查是否可以访问某些主机。
line 113: oaiBaseURL = "http://www.cnn.com";//////////////////////////////////////
line 114: boolean res = InetAddress.getByName(oaiBaseURL).isReachable(10000);
line 115: System.out.println("------reachable:"+res);
并获得以下错误消息(在 Eclipse 中):
java.net.UnknownHostException: http://www.cnn.com
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at com.irWizard.web.validator.WizardValidator.validateForm(WizardValidator.java:114)
有谁知道这个错误可能是什么原因?
提前致谢!