//Ping IP/域名
public static String pingIPCennect(String ipStr)
{
String result = "";
if (!ipStr.equals(""))
{ try {
int timeOut = 3000;
InetAddress address = InetAddress.getByName(ipStr);
if (address.isReachable(timeOut)) {
result = "IP/Host Name:" + ipStr + " is OK";
} else {
result = "IP/Host Name:" + ipStr + " is LOSS";
}
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}
转载于:https://www.cnblogs.com/wenxiangchen/p/3517038.html