java获取网卡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; } }
feiyue3008