Java Utililty Methods Network Interface Get

List of utility methods to do Network Interface Get

Description

The list of methods to do Network Interface Get are organized into topic(s).

Method

NetworkInterfacegetInterfaceByName(String interfaceName)
get Interface By Name
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netIf : Collections.list(nets)) {
    if (netIf.getName().equalsIgnoreCase(interfaceName)) {
        return netIf;
    } else {
        Enumeration<NetworkInterface> subIfs = netIf.getSubInterfaces();
        for (NetworkInterface subIf : Collections.list(subIfs)) {
            if (subIf.getName().equalsIgnoreCase(interfaceName)) {
...
StringgetInterfaceDiagnostic()
It provides a complete description of all available network interfaces in the system as well as the configured INET Addresses.
StringBuilder description = new StringBuilder();
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netIf : Collections.list(nets)) {
    description.append(describeInterface(netIf, false));
    description.append(displaySubInterfaces(netIf));
    description.append("\n");
return description.toString();
...
StringgetInterfaceInfo(NetworkInterface nif)
get Interface Info
return getInterfaceInfo(nif, ":");
MapgetInterfaces()
get Interfaces
Map<String, String> interfaces = new HashMap<String, String>();
try {
    Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
    while (e.hasMoreElements()) {
        NetworkInterface ni = (NetworkInterface) e.nextElement();
        String nameInterface = ni.getName();
        Enumeration<InetAddress> e2 = ni.getInetAddresses();
        while (e2.hasMoreElements()) {
...
ListgetInterfaces()
Return all interfaces (and subinterfaces) on the system
List<NetworkInterface> all = new ArrayList<NetworkInterface>();
addAllInterfaces(all, Collections.list(NetworkInterface.getNetworkInterfaces()));
return all;
ListgetInterfaces()
get Interfaces
List<InterfaceAddress> result = new ArrayList<InterfaceAddress>();
try {
    Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
    while (en.hasMoreElements()) {
        NetworkInterface ni = (NetworkInterface) en.nextElement();
        for (InterfaceAddress address : ni.getInterfaceAddresses()) {
            if (!address.getAddress().getHostAddress().contains(":")
                    && !address.getAddress().getHostAddress().contains("127.0.0.1"))
...
ListgetInterfaces()
get Interfaces
Enumeration<NetworkInterface> intfs = NetworkInterface.getNetworkInterfaces();
List<NetworkInterface> intfsList = new ArrayList<NetworkInterface>();
while (intfs.hasMoreElements()) {
    intfsList.add((NetworkInterface) intfs.nextElement());
return intfsList;
ListgetInterfaces()
This method returns a List of Network Interfaces on the computer.
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
return Collections.list(nets);
EnumerationgetInterfaces(final String interfaceName)
get Interfaces
return interfaceName != null
        ? new Vector<NetworkInterface>(Arrays.asList(NetworkInterface.getByName(interfaceName))).elements()
        : NetworkInterface.getNetworkInterfaces();
byte[]getKey()
get Key
Enumeration<NetworkInterface> ni = java.net.NetworkInterface.getNetworkInterfaces();
if (ni.hasMoreElements()) {
    byte[] mac = ni.nextElement().getHardwareAddress();
    if (mac != null) {
        return Arrays.copyOf(mac, 8);
    } else {
        return "aGorRiaA".getBytes();
} else {
    return "aGorRiaA".getBytes();