我正在乱用Java中的DNS服务 - 我特意尝试查找所有google.com地址并将其显示在数组中,类似于使用nslookup运行查找:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
Run Code Online (Sandbox Code Playgroud)
我正在使用InetAddress这个,但继续得到异常错误.由于错误引用了"未知主机",我认为InetAddress不能读取TXT记录(如果我使用google.com它可以工作,但这并不显示完整的IP范围).以下是我的代码:
InetAddress dnsresult[] = InetAddress.getAllByName("_netblocks.google.com");
for (int i=0; i<dnsresult.length; i++)
System.out.println (dnsresult[i]);
Run Code Online (Sandbox Code Playgroud)
如果有人能指出我正确的方向,我将不胜感激.
-JK