java如何取得mac地址
Macs Fan Control 是一款专为Mac设计的风扇控制工具,有效解决电脑过热问题。了解如何设置和使用,请访问官网。在数码荔枝购买正版序列号、获取下载,避免使用破解。
代码:publicstaticStringgetMACAddress(){Stringaddress="";Stringos=System.getProperty("os.name");System.out.println(os);if(os!=null&&os.startsWith("Windows")){try{ProcessBuilderpb=newProcessBuilder("ipconfig","/all");Processp=pb.start();BufferedReaderbr=newBu
代码:
public static String getMACAddress() {
String address = "";
String os = System.getProperty("os.name");
System.out.println(os);
if (os != null && os.startsWith("Windows")) {
try {
ProcessBuilder pb = new ProcessBuilder("ipconfig", "/all");
Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf("Physical Address") != -1) {
int index = line.indexOf(":");
address = line.substring(index + 1);
break;
}
}
br.close();
return address.trim();
} catch (IOException e) {
}
}
return address;
}

































