Resolving ip-address of a hostname

后端 未结 4 534
青春惊慌失措
青春惊慌失措 2020-12-02 14:59

I have the DNS server IP address and a hostname.

Using Java, how can I find the IP address of the hostname as returned by that DNS server using the IP address and th

4条回答
  •  佛祖请我去吃肉
    2020-12-02 15:39

    You can use InetAddress for this. Try the below code,

    InetAddress address = InetAddress.getByName("www.yahoo.com");
    System.out.println(address.getHostAddress());
    System.out.println(address.getHostName());
    

提交回复
热议问题