Here you can find the source of getInterface(InetAddress addr)
public static NetworkInterface getInterface(InetAddress addr)
//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; } } }