获取网卡mac地址 .txt
来自「java 的代码」· 文本 代码 · 共 24 行
TXT
24 行
/**
* 获取网卡MAC地址
*/
public static String getMacOnWindow() {
try {
String mac = null;
Process process = Runtime.getRuntime().exec("ipconfig /all");
BufferedReader buffer =
new BufferedReader(new InputStreamReader(process.getInputStream()));
for (String line = buffer.readLine(); line != null; line = buffer.readLine()) {
int index = line.indexOf("Physical Address");
if (index <= 0) {
continue;
}
mac = line.substring(index + 36);
break;
}
buffer.close();
process.waitFor();
return mac;
} catch (Exception exception) {
return null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?