List all Network Interface in Java
Description
The following code shows how to list all Network Interface.
Example
//from w w w . ja v a2 s . co m
import java.net.NetworkInterface;
import java.util.Enumeration;
public class Main {
public static void main(String[] args) throws Exception {
Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface) interfaces.nextElement();
System.out.println(ni);
}
}
}
The code above generates the following result.