如何获得Java中默认网络适配器的主机广播地址?
最佳答案
尝试这个:
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements())
{
NetworkInterface networkInterface = interfaces.nextElement();
if (networkInterface.isLoopback())
continue; // Do not want to use the loopback interface.
for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
InetAddress broadcast = interfaceAddress.getBroadcast();
if (broadcast == null)
continue;
// Do something with the address.
}
}
关于java - 如何获得默认网络适配器的主机广播地址? java ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29238644/