import java.net.InetAddress;
import java.net.UnknownHostException;
public class InetAddressTest
{
public static void main(String args[]) throws Exception
{
InetAddress address=InetAddress.getLocalHost();//该类没有明显的构造方法,但是有较多的静态方法,可直接调用
System.out.println(address);
address=InetAddress.getByName("www.baidu.com");
System.out.println(address);
}
}
InetAddress获取IP地址
最新推荐文章于 2024-08-09 10:01:17 发布