public static Enumeration < NetworkInterface > getNetworkInterfaces ( ) throws SocketException { final NetworkInterface [ ] netifs = getAll ( ) ; // specified to return null if no network interfaces if ( netifs == null ) return null ; return new Enumeration < NetworkInterface > ( ) { private int i = 0 ; public NetworkInterface nextElement ( ) { if ( netifs != null && i < netifs . length ) { NetworkInterface netif = netifs [ i ++ ] ; return netif ; } else { throw new NoSuchElementException ( ) ; } } public boolean hasMoreElements ( ) { return ( netifs != null && i < netifs . length ) ; } } ; }
Returns all the interfaces on this machine . Returns null if no network interfaces could be found on this machine .