package com.net.luzhiming;
import java.net.InetAddress;
public class InetAddressTest1 {
public static void main(String[] args) throws Exception {
System.out.println(InetAddress.getLocalHost());
System.out.println(InetAddress.getByName("www.baidu.com"));
}
}
InetAddress 获得Ip地址
最新推荐文章于 2024-08-09 10:01:17 发布
本文提供了一个简单的 Java 示例代码,展示了如何使用 InetAddress 类获取本地主机名及指定网站的 IP 地址。通过运行该示例代码,读者可以了解 InetAddress 类的基本用法。
1454

被折叠的 条评论
为什么被折叠?



