j通过本地dns解析获得域名的iP

InetAddress[] arr = InetAddress.getAllByName("www.qq.com");
for(InetAddress addr :arr) {
    if(addr instanceof Inet4Address) {
        System.out.println("ipv4 : "+addr.getHostAddress());
    } else if(addr instanceof Inet6Address){
        System.out.println("ipv6 : "+addr.getHostAddress());
    }
}
posted @ 2012-12-03 17:49  悟寰轩-叶秋  阅读(291)  评论(0编辑  收藏  举报