Java Network Interface Check printInterface(NetworkInterface netIf)

Here you can find the source of printInterface(NetworkInterface netIf)

Description

print Interface

License

Open Source License

Declaration

private static void printInterface(NetworkInterface netIf) throws SocketException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.*;

import java.util.Collections;
import java.util.Enumeration;
import static java.lang.System.out;

public class Main {
    private static void printInterface(NetworkInterface netIf) throws SocketException {
        out.printf("Display name: %s\n", netIf.getDisplayName());
        out.printf("Name: %s\n", netIf.getName());
        displaySubInterfaces(netIf);/*  w w  w .j a va2s  . c  o m*/
        out.printf("\n");
    }

    private static void displaySubInterfaces(NetworkInterface netIf) throws SocketException {
        Enumeration<NetworkInterface> subIfs = netIf.getSubInterfaces();

        for (NetworkInterface subIf : Collections.list(subIfs)) {
            out.printf("\tSub Interface Display name: %s\n", subIf.getDisplayName());
            out.printf("\tSub Interface Name: %s\n", subIf.getName());
        }
    }
}

Related

  1. isLoopbackNetworkInterface( NetworkInterface anInterface)
  2. isNetworkAvailable()
  3. isNetworkException(Exception e)
  4. isNetworkProblem(final Throwable ex)
  5. isUpAndNotLoopback(final NetworkInterface ni)
  6. retrieveNetworkInterfaces()
  7. sortInterfaces(List interfaces)