欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

得到网站的IP地址,网站IP地址,通过InetAddres

来源: javaer 分享于  点击 35951 次 点评:38

得到网站的IP地址,网站IP地址,通过InetAddres


通过InetAddress的getHostAddress方法得到网站的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());        }    }//该片段来自于http://byrx.net
相关栏目:

用户点评