Java Network Interface Get getNetworkInterfaceInfo(NetworkInterface pNif)

Here you can find the source of getNetworkInterfaceInfo(NetworkInterface pNif)

Description

get Network Interface Info

License

Apache License

Declaration

private static String getNetworkInterfaceInfo(NetworkInterface pNif) throws SocketException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;
import java.net.*;

public class Main {
    private static Method isUp;
    private static Method supportsMulticast;

    private static String getNetworkInterfaceInfo(NetworkInterface pNif) throws SocketException {
        if (pNif == null) {
            return "[null]";
        }/*  w w  w. j  av a 2  s .c  om*/
        return pNif.getDisplayName() + " [up: " + pNif.isUp() + ", mc: " + pNif.supportsMulticast() + ", lb: "
                + pNif.isLoopback() + ", hw: " + formatHwAddress(pNif.getHardwareAddress()) + "]";
    }

    private static String formatHwAddress(byte[] pHardwareAddress) {
        if (pHardwareAddress == null) {
            return "[none]";
        }
        StringBuilder sb = new StringBuilder(18);
        for (byte b : pHardwareAddress) {
            if (sb.length() > 0) {
                sb.append(':');
            }
            sb.append(String.format("%02x", b));
        }
        return sb.toString();
    }
}

Related

  1. getNetworkInterface()
  2. getNetworkInterface()
  3. getNetworkInterface(String name)
  4. getNetworkInterfaceArray(String name)
  5. getNetworkinterfaceByName(String name)
  6. getNetworkInterfaces( Predicate predicate)
  7. getNetworkInterfaces()
  8. getNetworkInterfaces()
  9. getNetworkInterfaces()