标签:res 机器 stat bsp get ima mamicode cep ring
public class InetAddressDemo { public static void main(String[] args) throws UnknownHostException { //public static InetAddress getByName(String host) 确定主机名称的IP地址。主机名称可以是机器名称 InetAddress id = InetAddress.getByName("192.168.50.76"); //public String getHostName()获取此IP地址的主机名。 String hostName = id.getHostName(); System.out.println("主机名:"+hostName); //public String getHostAddress()返回文本显示中的IP地址字符串。 String hostAddress = id.getHostAddress(); System.out.println("IP地址:"+hostAddress); } }
运行结果:
标签:res 机器 stat bsp get ima mamicode cep ring
原文地址:https://www.cnblogs.com/pxy-1999/p/12838128.html