Java Utililty Methods Host Ping

List of utility methods to do Host Ping

Description

The list of methods to do Host Ping are organized into topic(s).

Method

booleanping(final String host, final int timeout)
ping
try {
    final InetAddress address = InetAddress.getByName(host);
    return address.isReachable(timeout);
} catch (Throwable ignored) {
return false;
booleanping(String host)
Checks if the Host is Reachable
try {
    return InetAddress.getByName(host).isReachable(100);
} catch (IOException e) {
    return false;
booleanping(String host, int timeout)
ping
pingErrorMessage = "No Error";
try {
    InetAddress address = InetAddress.getByName(host);
    return address.isReachable(timeout);
} catch (Exception e) {
    pingErrorMessage = e.getMessage();
    return false;
booleanping(String host, int timeout)
ping
try {
    return InetAddress.getByName(host).isReachable(timeout);
} catch (Exception e) {
    return false;
voidPing(String host, int timeout)
Tes apakah host/IP bisa dihubungi
try {
    if (InetAddress.getByName(host).isReachable(timeout)) {
        System.out.printf("%s is reachable %n", host);
    } else {
        System.out.printf("%s is unreachable %n", host);
} catch (UnknownHostException ex) {
    System.out.printf("Unknown host: %s%n", host);
...
booleanping(String host, int timeout)
ping
InetAddress address = null;
try {
    address = InetAddress.getByName(host);
} catch (UnknownHostException e) {
    e.printStackTrace();
    return false;
boolean b = false;
...