/**
* 获取widnows网卡的mac地址.
* @return mac地址
*/
public static List<String> getWindowsMACAddress() {
List<String> list = new ArrayList<String>();
String mac = null;
BufferedReader bufferedReader = null;
Process process = null;
try {
process = Runtime.getRuntime().exec("ipconfig /all");// windows下的命令,显示信息中包含有mac地址信息
bufferedReader = new BufferedReader(new InputStreamReader(process
.getInputStream()));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
try {
if(( mac =line.substring(line.indexOf(":")+2, line.length())).length()== 17&& mac.matches("\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}-\\w{2}") ){
list.add(mac);
}
} catch (Exception e) {
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e1) {
e1.printStackTrace();
}
bufferedReader = null;
process = null;
}
return list;
}