public static Collection < InetAddress > getNetworkInterfaces ( ) throws SocketException { final Collection < InetAddress > addresses = new ArrayList < InetAddress > ( ) ; final Enumeration < NetworkInterface > e = NetworkInterface . getNetworkInterfaces ( ) ; while ( e . hasMoreElements ( ) ) { final NetworkInterface ni = e . nextElement ( ) ; final Enumeration < InetAddress > niAddresses = ni . getInetAddresses ( ) ; while ( niAddresses . hasMoreElements ( ) ) { addresses . add ( niAddresses . nextElement ( ) ) ; } } return addresses ; }
Utility method for accessing public interfaces .