通过网址获取IP

import java.net.*;
import java.io.*;
public class InetAddressTest {
    public static void main(String args[])
    {
        try{
        InetAddress SunAddress  =  InetAddress.getByName("blog.yeskn.com");
        System.out.println(" 计算机名:"+SunAddress.getHostName());
        System.out.println(" IP地址:"+SunAddress.getHostAddress());
        }
        catch(Exception e)
        {
            System.out.println("ERROR:"+e);
        }
        System.out.println();

    }

}

发表评论

电子邮件地址不会被公开。 必填项已用*标注