//java1.5(有时候机器可以ping通,代码显示false)
public static boolean ping(String ipAddress) throws Exception {
int timeOut = 10000 ; //超时应该在3钞以上
return InetAddress.getByName(ipAddress).isReachable(timeOut);
}//推荐使用
public static boolean ping(String ipAddress) throws Exception {
return 0==Runtime.getRuntime().exec("ping -c 1 "+ipAddress).waitFor();
}
java通过ping测试网络
最新推荐文章于 2024-06-29 03:29:08 发布