直播卖货系统开发,获取wifi/热点/有线的Ip地址的相关代码
try { for (Enumeration<NetworkInterface> mEnumeration = NetworkInterface .getNetworkInterfaces(); mEnumeration.hasMoreElements(); ) { NetworkInterface mInf = mEnumeration.nextElement(); for (Enumeration<InetAddress> IpAddress = mInf .getInetAddresses(); IpAddress .hasMoreElements(); ) { InetAddress inetAddress = IpAddress.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address ) { if (!inetAddress.getHostAddress().equals("null") && inetAddress.getHostAddress() != null) { // displayName的类型有:eth0是有线网络地址,wlan0是无线网络,ap0是热点 if (mInf.getDisplayName().equals("eth0")) { System.out.println("这是本机有线网络:" + inetAddress .getHostAddress()); } else if (mInf.getDisplayName().equals("ap0")) { System.out.println("这是本机热点:" + inetAddress .getHostAddress()); } else if (mInf.getDisplayName().equals("wlan0")) { System.out.println("这是本机wifi:" + inetAddress .getHostAddress()); } } } } } } catch (Exception e) { e.printStackTrace(); }以上就是直播卖货系统开发,获取wifi/热点/有线的Ip地址的相关代码, 更多内容欢迎关注之后的文章