Android 域名解析为IP的方法

来源:互联网 发布:2016淘宝追加评论期限 编辑:程序博客网 时间:2024/05/22 20:27
Android域名解析为IP的方法
try{ InetAddress x = java.net.InetAddress.getByName("www.baidu.com");             String ip_devdiv = x.getHostAddress();//得到字符串形式的ip地址             Log.d("putoutmsg", "百度IP地址为:"+ip_devdiv); } catch (UnknownHostException e) { e.printStackTrace();             Log.d("putoutmsg", "域名解析出错"); }
0 0