设为首页 加入收藏

TOP

Java获取网卡的mac地址(二)
2014-11-24 00:58:14 来源: 作者: 【 】 浏览:7
Tags:Java 获取 网卡 mac 地址
catch (Exception ex) {
System.out.println("windows 7方式未获取到网卡地址");
}
return sb.toString();
}


/**
* 获取MAC地址
*
* @param argc
* 运行参数.
* @throws Exception
*/
public static String getMACAddress() {
// windows
String mac = getWindowsMACAddress();
// windows7
if (isNull(mac)) {
mac = getWindows7MACAddress();
}
// unix
if (isNull(mac)) {
mac = getUnixMACAddress();
}


if (!isNull(mac)) {
mac = mac.replace("-", "");
}
else {
mac = "ABCDEFGHIJ";
}
return mac.toLowerCase();
}


public static boolean isNull(Object strData) {
if (strData == null || String.valueOf(strData).trim().equals("")) {
return true;
}
return false;
}


public static void main(String[] args) {
System.out.println(getWindows7MACAddress());
}


}


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++自定义异常类 下一篇Java提取每个汉字的首字母

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: