converting an IP address to host name

前端 未结 4 1803
臣服心动
臣服心动 2020-12-03 22:26

In my java application if user enters the IP we need to display the host name, if host name is given then we need to display the IP of the host.

For example if user

4条回答
  •  醉梦人生
    2020-12-03 22:47

    If you are coding in Java, try using InetAddress

    InetAddress addr = InetAddress.getByName("173.194.36.37");
    String host = addr.getHostName();
    System.out.println(host);
    

提交回复
热议问题