public static String getMACAddress(){
String address = "";
String os = System.getProperty("os.name");
String osUser=System.getProperty("user.name");
if (os != null && os.startsWith("Windows")) {
try {
String command = "cmd.exe /c ipconfig /all";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br =new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf("Physical Address") > 0) {
int index = line.indexOf(":");
indx += 2;
address = line.substring(index);
break;
}
}
br.close();
return address.trim();
}
catch (IOException e) {
}
}
return address;
}
获得网卡地址
原创152LvBigGrandPa ©著作权
©著作权归作者所有:来自51CTO博客作者152LvBigGrandPa的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:多级菜单
下一篇:layout混合布局
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
使用nmcli修改双网卡主机ip地址,划分vlan
nmcli 是一个用于控制NetworkManager的命令行工具,可以用于在 Linux 系统中管理网络连接。
linux双网卡 Centos stream 9 rocky 9 vlan nmcli -
centos 双网卡配置
双网卡
双网卡 -
Getmac-获得网卡的MAC地址
Getmac-获得网卡的MAC地址
职场 休闲 Getmac-获得网卡的MAC地址