返回顶部

收藏

java获得网站的IP地址

更多

通过InetAddress的getHostAddress方法得到网站的IP地址

得到网站的IP地址

public static void main(String[] args){
        try{
            String siteName = "";
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Please input the Site Name just like 'www.Google.com':");
            siteName = br.readLine();
            InetAddress in = InetAddress.getByName(siteName);
            System.out.println("The WebSite Ip Address is: "+in.getHostAddress());
        }catch(Exception e){
            System.out.println("Some Exception has occurred with details"+e.getMessage());
        }
    }

标签:java,IP

收藏

0人收藏

支持

0

反对

0

发表评论