通过ip获取用户的mac地址
public String getMyIP() { try { return request.getRemoteAddr(); } catch (Exception e) { e.printStackTrace(); } return ""; } public String getMACAddress(String ip){ String str = ""; String macAddress = ""; try{ Process p = Runtime.getRuntime().exec("nbtstat -A " + ip); InputStreamReader ir = new InputStreamReader(p.getInputStream()); LineNumberReader input = new LineNumberReader(ir); for (int i = 1; i < 100; i++) { str = input.readLine(); if (str != null) { if (str.indexOf("MAC Address") > 1) { macAddress = str.substring(str.indexOf("MAC Address") + 14, str.length()); break; } } } } catch (IOException e) { e.printStackTrace(System.out); } return macAddress; }