public String getMacAddress() throws Exception{
InetAddress inetAddress = InetAddress.getLocalHost(); byte[] mac = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress(); StringBuffer sb = new StringBuffer("");for(int i=0; i<mac.length; i++) {
if(i!=0) { sb.append("-"); } int temp = mac[i]&0xff; String str = Integer.toHexString(temp); if(str.length()==1) { sb.append("0"+str); }else { sb.append(str); } } return sb.toString().toUpperCase(); }