Java示例确定本地IP地址 Java示例从IP地址查找主机名 Java示例检查端口 Java示例确定本地IP地址 import java.net.InetAddress; public class Main { public static void main(String[] args) throws Exception { InetAddress addr = InetAddress.getLocalHost(); System.out.println("Local HostAddress: "+addr.getHostAddress()); String hostname = addr.getHostName(); System.out.println("Local host name: "+hostname); } } Java示例从IP地址查找主机名 Java示例检查端口