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

 

posted @ 2018-12-06 14:58  席纳霍霍  阅读(118)  评论(0编辑  收藏  举报