Java InetAddress Create getInterface(InetAddress addr)

Here you can find the source of getInterface(InetAddress addr)

Description

Return the Network Interface object that has the given InetAddress configured on it.

License

Open Source License

Declaration

public static NetworkInterface getInterface(InetAddress addr) 

Method Source Code

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

import java.net.*;

public class Main {
    /**//from  ww  w.j  a  va 2  s  .c  om
     * Return the Network Interface object that has the given InetAddress configured
     * on it. Returns {@code null} if there are any errors locating the interface.
     */
    public static NetworkInterface getInterface(InetAddress addr) {
        try {
            return NetworkInterface.getByInetAddress(addr);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * Return the Network Interface object identified with the given name. Returns
     * {@code null} if there are any errors locating the interface.
     */
    public static NetworkInterface getInterface(String name) {
        try {
            return NetworkInterface.getByName(name);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. getInetAddressFromConfigString( String fixedDeviceConfigSring)
  2. getInetAddressFromString(String s)
  3. getInetAddressMap()
  4. getInetAddressMap()
  5. getInt32FromAddress(Inet4Address inetAddress)
  6. getIP(InetAddress ip)
  7. getIP(InetAddress ip)
  8. getIP(InetAddress ip)
  9. getIPAsLong(InetAddress address)