Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/DNS-query/Java/dns-query-3.java
Normal file
21
Task/DNS-query/Java/dns-query-3.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import java.net.InetAddress;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
class DnsQuery {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
InetAddress[] ipAddr = InetAddress.getAllByName("www.kame.net");
|
||||
for(int i=0; i < ipAddr.length ; i++) {
|
||||
if (ipAddr[i] instanceof Inet4Address) {
|
||||
System.out.println("IPv4 : " + ipAddr[i].getHostAddress());
|
||||
} else if (ipAddr[i] instanceof Inet6Address) {
|
||||
System.out.println("IPv6 : " + ipAddr[i].getHostAddress());
|
||||
}
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
System.err.println("unknown host");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue