public static ArrayList<String> getMACAddress()
{
String address = "";
ArrayList al = new ArrayList();
String os = System.getProperty("os.name");
System.out.println(os);
if ( os != null && os.startsWith("Windows"))
{
try {
String command = "cmd.exe /c ipconfig /all";
//String command = "cmd.exe /c systemInfo";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br =new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null)
{
//System.out.println(line);
if (line.indexOf("Physical Address") > 0 || line.indexOf("物理アドレス") > 0)
{
int index = line.indexOf(":");
index += 2;
address = line.substring(index).trim();
System.out.println(address);
al.add(address);
// break;
}
}
br.close();
return al;
}
catch (IOException e)
{
}
}
return al;
}
JAVA网卡取得
最新推荐文章于 2024-04-14 01:03:57 发布