public static String getMacFor ( NetworkInterface iface ) throws SocketException , NoMacAddressException { assert ( iface != null ) ; byte [ ] hwaddr = iface . getHardwareAddress ( ) ; if ( hwaddr == null || hwaddr . length == 0 ) { throw new NoMacAddressException ( "Interface " + iface . getName ( ) + " has no physical address specified." ) ; } else { return physicalAddressToString ( hwaddr ) ; } }
Given a network interface determines its mac address