首页 > > > 为什么通过getByName(主机号或IP)问题
为什么通过getByName(主机号或IP),其中用IP地址,通过读取IP地址的主机名,为什么读取出来的是ip地址而不是主机名
1 public class Demo1 {
2
3 public static void main(String[] args) throws UnknownHostException {
4 //通过getByName("主机名或IP号")获取别人的ip地址对象
5 InetAddress inetAddress =InetAddress.getByName("183.232.231.172");
6 System.out.println("IP地址:"+inetAddress.getHostAddress());
7 System.out.println("主机名:"+inetAddress.getHostName());
8 }
9
10 }代码结果截图:

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/75/viewspace-3154204/ ,如需转载,请注明出处,否则将追究法律责任。