Welcome 微信登录

首页 / 操作系统 / Linux / JAVA获得域名的IP地址

import java.net.InetAddress; import java.net.UnknownHostException; public class TestInetAddress { InetAddress myIpAddress = null; InetAddress[] myServer = null; public static void main(String args[]) { TestInetAddress address = new TestInetAddress(); System.out.println("Your host IP is: " + address.getLocalhostIP()); String domain = "www.163.com"; System.out.println("The server domain name is: " + domain); InetAddress[] array = address.getServerIP(domain); int count=0; for(int i=1; i