converting an IP address to host name

前端 未结 4 1812
臣服心动
臣服心动 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:46

    The project SomeKittens referred to you looks like a complete DNS server written in Java, which might be more than you need. Have a look at java.net.InetAddress:

    java.net.InetAddress.getByName("example.com").getHostAddress();
    

提交回复
热议问题