...te dejo un ejemplo, la idea es usar InetAddress.isReachable();
Código Java:
Ver originalpublic static boolean ping
(String ipAddress
) { try {
final String IPADDRESS_PATTERN
= "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
Matcher matcher = pattern.matcher(ipAddress);
if(matcher.matches()) {
return InetAddress.
getByName(ipAddress
).
isReachable(5000); } else {
return false;
}
Logger.
getLogger(Utilities.
class.
getName()).
log(Level.
SEVERE,
null, ex
); return false;
}
}