一、获取本机的ip地址
InetAddress.getLocalHost().getHostAddress()
二、获取网址的地址
InetAddress.getByName("bi-new.tower0788.cn").getHostAddress()
三、获取网址的真实IP地址
InetAddress.getByName("www.heromutual.com")
四、获取配置在HOST中的域名IP地址
InetAddress.getByName("www.heromutual.com").getHostAddress()
总结:
@Test
public void test03265() throws Exception{
//获取本机IP地址
System.out.println(InetAddress.getLocalHost().getHostAddress());
System.out.println("=============");
//获取www.luoruiyuan.cn的地址
System.out.println(InetAddress.getByName("bi-new.tower0788.cn").getHostAddress());
System.out.println("=============");
//获取www.luoruiyuan.cn的真实IP地址
System.out.println(InetAddress.getByName("www.heromutual.com"));
System.out.println("=============");
//获取配置在HOST中的域名IP地址
System.out.println(InetAddress.getByName("www.heromutual.com").getHostAddress());
}