public static long getMacAddr ( ) { if ( macAddr == 0 ) { try { InetAddress ip = InetAddress . getLocalHost ( ) ; NetworkInterface network = NetworkInterface . getByInetAddress ( ip ) ; byte [ ] mac = network . getHardwareAddress ( ) ; for ( byte temp : mac ) { macAddr = ( macAddr << 8 ) | ( ( int ) temp & 0xFF ) ; } } catch ( Exception e ) { macAddr = 0 ; } } return macAddr ; }
Returns host s MAC address .