Posted on 2007-12-25 16:47
sugo 阅读(364)
评论(0) 编辑 收藏
获取网卡物理地址:
String cmd="ipconfig /all";
Process p=Runtime.getRuntime().exec(cmd);
BufferedReader bis=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line="";
while((line=bis.readLine())!=null){
if(line.indexOf("Physical Address")!=-1){
Pattern ptn=Pattern.compile("((\\w{2})|(\\d{2})|(\\w+\\d+)|(\\d+\\w+))-.*");
Matcher m=ptn.matcher(line.trim());
while(m.find()){
System.out.println("get mac "+m.group());
}
}
}