//获取本机IP
public static String get_ip() throws Exception {
InetAddress localHost = InetAddress.getLocalHost();
return localHost.getHostAddress();
}
//获取MAC
public static String get_mac() throws Exception {
InetAddress localHost = InetAddress.getLocalHost();
byte[] mac = NetworkInterface.getByInetAddress(localHost).getHardwareAddress();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < mac.length; i++) {
if (i != 0) {
sb.append("-");
}
String s = Integer.toHexString(mac[i] & 0xFF);
sb.append(s.length() == 1 ? 0 + s : s);
}
return sb.toString();
}