我通过IP地址获取的InetAddress实例,输出的主机名仍然是 ip地址。
InetAddress address2 = InetAddress.getByName("192.168.2.102");
System.out.println("计算名:" + address2.getHostName());
System.out.println("IP地址:" + address2.getHostAddress());
运行结果:
计算名:192.168.2.102
IP地址:192.168.2.102