for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) {
System.out.println(inetAddress.getHostAddress());
}
}
}
这将返回所有本地IP地址。如果我连接到GPRS,它会返回另一个私有A类IP地址,我想过滤掉它(因为我不知道这个网络是什么或它是如何工作的)。
我基本上需要WiFi / WiFi HotSpot / USB HotSpot / WiFi Direct IP地址。
这个GPRS接口是否只能连接到一个设备(我的)?