Check if network support multicast in Java
Description
The following code shows how to check if network support multicast.
Example
import java.net.NetworkInterface;
import java.util.Enumeration;
// w ww. j ava2 s .c om
public class Main {
public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface ni = en.nextElement();
System.out.println(" Display Name = " + ni.getDisplayName());
System.out.println(" Support multicast = " + ni.supportsMulticast());
}
}
}
The code above generates the following result.