NetworkInterface: getDisplayName() : NetworkInterface « java.net « Java by API






NetworkInterface: getDisplayName()

  
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

public class Main {
  public static void main(String args[]) throws SocketException {
    Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
    for (NetworkInterface netint : Collections.list(nets)) {
      displayInterfaceInformation(netint);
    }
  }

  private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
    System.out.printf("Display name: %s%n", netint.getDisplayName());
    System.out.printf("Name: %s%n", netint.getName());
    Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
    for (InetAddress inetAddress : Collections.list(inetAddresses)) {
      System.out.printf("InetAddress: %s%n", inetAddress);
    }
    System.out.printf("%n");
  }
}

   
    
  








Related examples in the same category

1.NetworkInterface: getByInetAddress(InetAddress addr)
2.NetworkInterface: getHardwareAddress()
3.NetworkInterface: getHardwareAddress() throws SocketException
4.NetworkInterface: getInetAddresses()
5.NetworkInterface: getInterfaceAddresses()
6.NetworkInterface: getMTU()
7.NetworkInterface: getName()
8.NetworkInterface: isLoopback()
9.NetworkInterface: isPointToPoint()
10.NetworkInterface: isUp()
11.NetworkInterface: isVirtual()
12.NetworkInterface: supportsMulticast()