获取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()); } }