Java study notes-InetAddress get ip

Get current ip address

System.out.println(InetAddress.getLocalHost());

 

Get the IP address corresponding to the domain name

InetAddress.getByName("www.baidu.com").getHostAddress();

 

 

Guess you like

Origin blog.csdn.net/mumuwang1234/article/details/112477290