Java examples for Network:Network Interface
Listing the Available Network Interface on a Machine
import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class Main { public static void main(String[] args) { try {/*from w w w . j av a 2 s. com*/ Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface nif = e.nextElement(); System.out.println("Name: " + nif.getName() + ", Supports Multicast: " + nif.supportsMulticast() + ", isUp(): " + nif.isUp()) ; } } catch (SocketException ex) { ex.printStackTrace(); } } }