Android Ping

xiaoxiao2021-02-28  114

boolean success=false; Process p =null; try { String ip= "192.168.1.111"; p = Runtime.getRuntime().exec("ping -c 1 -i 0.2 -W 1 " +ip); int status = p.waitFor(); if (status == 0) { success=true; } else { success=false; } } catch (IOException e) { success=false; } catch (InterruptedException e) { success=false; }finally{ p.destroy(); }
转载请注明原文地址: https://www.6miu.com/read-39982.html

最新回复(0)