我有一些使用InetAddress.getByName
的代码。我不断地得到UnknownHostException
:
java.net.UnknownHostException: google.com: System error
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
at java.net.InetAddress.getAllByName(InetAddress.java:1162)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at java.net.InetAddress.getByName(InetAddress.java:1048)
执行nslookup google.com
工作,故障本身偶尔也会发生。可能导致这种情况的原因是什么?
答案 0 :(得分:0)
尝试查看official java documentation
抛出: UnknownHostException - 如果找不到主机的IP地址,或者为全局IPv6地址指定了scope_id。