如何使用java代码自动获取计算机的ip地址和mac地址
求java代码
2条回答 默认 最新
oyljerry 2014-12-26 09:54关注public static String getMacAddressIP(String remotePcIP) { String str = ""; String macAddress = ""; try { Process pp = Runtime.getRuntime().exec("nbtstat -A " + remotePcIP); InputStreamReader ir = new InputStreamReader(pp.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 ex) { } return macAddress; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报