List Network Interfaces : NetworkInterface « Network Protocol « Java






List Network Interfaces

  
import java.net.NetworkInterface;
import java.util.Enumeration;

public class Main {
  static public void main(String args[]) throws Exception {
    Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
    while (interfaces.hasMoreElements()) {
      NetworkInterface ni = (NetworkInterface) interfaces.nextElement();
      System.out.println(ni);
    }
  }
}

   
    
  








Related examples in the same category

1.Programmatic Access to Network Parameters
2.An updated version of the ListNets program that uses the NetworkInterface enhancements
3.Get MAC address of a host: java.net.NetworkInterface.getHardwareAddress().
4.Report By Name
5.Extract network card address with java.net.NetworkInterface
6.Class for determining a host's IP address.