@ Pure public static Map < InetAddress , MACNumber > getAllMappings ( ) { final Map < InetAddress , MACNumber > av = new HashMap <> ( ) ; final Enumeration < NetworkInterface > interfaces ; try { interfaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException exception ) { return av ; } if ( interfaces != null ) { NetworkInterface inter ; MACNumber mac ; InetAddress inet ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; try { final byte [ ] addr = inter . getHardwareAddress ( ) ; if ( addr != null ) { mac = new MACNumber ( addr ) ; final Enumeration < InetAddress > inets = inter . getInetAddresses ( ) ; while ( inets . hasMoreElements ( ) ) { inet = inets . nextElement ( ) ; av . put ( inet , mac ) ; } } } catch ( SocketException exception ) { // Continue to the next loop. } } } return av ; }
Get all of the internet address and ethernet address mappings on the local machine .