import java.net.NetworkInterface;
import java.net.InetAddress;
public String getMacAddress() {
InetAddress ia = null;
byte[] mac = new byte[0];
try {
ia = InetAddress.getLocalHost();
mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
} catch (Throwable e) {
e.printStackTrace();
return "";
}
StringBuffer buffer = new StringBuffer("");
for(int i=0; i<mac.length; i++) {
if(i!=0) {
buffer.append("-");
}
int temp = mac[i]&0xff;
String str = Integer.toHexString(temp);
if(str.length()==1) {
buffer.append("0"+str);
}else {
buffer.append(str);
}
}
String aCase = buffer.toString().toUpperCase();
System.out.println(aCase);
return aCase;
}