diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java index 315b591..5820e08 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java @@ -392,19 +392,17 @@ public class VirtualCallService { return macAddress; } - //获取非本地IP的MAC地址 - Process p = Runtime.getRuntime().exec("arp " + ip); - InputStreamReader isr = new InputStreamReader(p.getInputStream()); - BufferedReader br = new BufferedReader(isr); - while ((line = br.readLine()) != null) { - if (line != null) { - int index = line.indexOf(MAC_ADDRESS_PREFIX); - if (index != -1) { - macAddress = line.substring(index + MAC_ADDRESS_PREFIX.length()).trim().toUpperCase(); - } - } + Process process = Runtime.getRuntime().exec("arp "+ip); + InputStreamReader ir = new InputStreamReader(process.getInputStream()); + LineNumberReader input = new LineNumberReader(ir); + StringBuffer s = new StringBuffer(); + while ((line = input.readLine()) != null) { + s.append(line); + } + macAddress = s.toString(); + if (macAddress != null) { + macAddress = macAddress.substring(macAddress.indexOf(":") - 2, macAddress.lastIndexOf(":") + 3); } - br.close(); } catch (IOException e) { e.printStackTrace(System.out); }