InetAddress


package test;

import java.io.IOException;
import java.net.InetAddress;

public class Test {  
	  
    public static void main(String[] args) throws IOException {
    	String url="www.baidu.com";//不知为什么加上http://报错
    	InetAddress address=InetAddress.getByName(url);
    	System.out.println("baidu的IP地址:" + address.getHostAddress()) ;
    }
    
   
    /**
     *baidu的IP地址:119.75.217.109
		
     */
}


posted @ 2017-08-08 08:08  jhcelue  阅读(168)  评论(0编辑  收藏  举报