java-ip

IP地址的封装类

InterAddress host=InterAddress.getLocalHost();//获取本地地址
InterAddress host=InterAddress.getByName(“192.168.0.1”);//获取指定IP地址
InterAddress host=InterAddress.getByName(“www.baidu.com”);//域名地址
InterAddress host=InterAddress.getByName(“WIN-ADSFASDFASD”);//获取计算机名
InterAddress [] hosts=InterAddress.getAllByAllByName(“www.baidu,com”);//获取主机的所有的地址

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/huiguo_/article/details/109037318