获取手机的IP地址(IPV4)
2016-03-02 11:02
399 查看
public static String GetIp() { try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> ipAddr = intf.getInetAddresses(); ipAddr .hasMoreElements();) { InetAddress inetAddress = ipAddr.nextElement(); // ipv4地址 if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress .getHostAddress())) { return inetAddress.getHostAddress(); } } } } catch (Exception ex) { } return ""; }
相关文章推荐
- <td>中文字垂直居中
- Android Gradle Build Error:Some file crunching failed, see logs for details解决办法
- 我们为什么要遵循W3C标准规范
- 猜年龄游戏,输入数字,直到猜对为止
- 海南出差报告总结(案件录入与案件追踪系统)
- HBase设计与开发性能优化(转)
- 欢迎使用CSDN-markdown编辑器
- applicationContext.xml路径
- java中的for 循环的几种用法解析
- perl tk 资料widget
- 设置ScrollView中的控件高度充满父窗体
- 在使用GridView的时候点击内部控件不显示背景
- Nagios中常见参数的含义
- Android布局文件中命名空间的解析
- HBase配置性能调优(转)
- 通过Java Api与HBase交互(转)
- 链表的实现与数组
- 分割字符串的一个demo
- myeclipse提交到github出现错误 non-fast-forward
- [memory]虚拟地址空间分布