DNS query: Difference between revisions

(DNS query in FreeBASIC)
Line 1,229:
 
=={{header|Java}}==
This is the same implementation as below, just less code
<syntaxhighlight lang="java">
import java.net.InetAddress;
import java.net.UnknownHostException;
</syntaxhighlight>
<syntaxhighlight lang="java">
public static void main(String[] args) throws UnknownHostException {
/* 'getAllByName' will use the system configured 'resolver' */
for (InetAddress ip : InetAddress.getAllByName("www.kame.net"))
System.out.println(ip.getHostAddress());
}
</syntaxhighlight>
<pre>
210.155.141.200
2001:2f0:0:8800:226:2dff:fe0b:4311
2001:2f0:0:8800:0:0:1:1
</pre>
<br />
An alternate demonstration
<syntaxhighlight lang="java">import java.net.InetAddress;
import java.net.Inet4Address;
118

edits