获取IP地址

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.*;
public class getIP{
    public static void main(String[] args) throws IOException {
       InetAddress addr = InetAddress.getByName("www.baidu.com");//
       
       System.out.println("IP=  "+ addr.getHostAddress());    
    }
}
原文地址:https://www.cnblogs.com/zy791976083/p/10076730.html