Commit 66035957ea76de2e1623d2e9a6c7ce3af8df3917
1 parent
6e5b7b874c
Exists in
master
and in
6 other branches
虚拟叫号
Showing 1 changed file with 10 additions and 12 deletions
platform-operate-api/src/main/java/com/lyms/hospitalapi/whfy/VirtualCallService.java
View file @
6603595
... | ... | @@ -392,19 +392,17 @@ |
392 | 392 | return macAddress; |
393 | 393 | } |
394 | 394 | |
395 | - //获取非本地IP的MAC地址 | |
396 | - Process p = Runtime.getRuntime().exec("arp " + ip); | |
397 | - InputStreamReader isr = new InputStreamReader(p.getInputStream()); | |
398 | - BufferedReader br = new BufferedReader(isr); | |
399 | - while ((line = br.readLine()) != null) { | |
400 | - if (line != null) { | |
401 | - int index = line.indexOf(MAC_ADDRESS_PREFIX); | |
402 | - if (index != -1) { | |
403 | - macAddress = line.substring(index + MAC_ADDRESS_PREFIX.length()).trim().toUpperCase(); | |
404 | - } | |
405 | - } | |
395 | + Process process = Runtime.getRuntime().exec("arp "+ip); | |
396 | + InputStreamReader ir = new InputStreamReader(process.getInputStream()); | |
397 | + LineNumberReader input = new LineNumberReader(ir); | |
398 | + StringBuffer s = new StringBuffer(); | |
399 | + while ((line = input.readLine()) != null) { | |
400 | + s.append(line); | |
406 | 401 | } |
407 | - br.close(); | |
402 | + macAddress = s.toString(); | |
403 | + if (macAddress != null) { | |
404 | + macAddress = macAddress.substring(macAddress.indexOf(":") - 2, macAddress.lastIndexOf(":") + 3); | |
405 | + } | |
408 | 406 | } catch (IOException e) { |
409 | 407 | e.printStackTrace(System.out); |
410 | 408 | } |