Java Utililty Methods Host Ping

List of utility methods to do Host Ping

  1. HOME
  2. Java
  3. H
  4. Host Ping

Description

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

Method

boolean ping(final String host, final int timeout)
ping
try {
 final InetAddress address = InetAddress.getByName(host);
 return address.isReachable(timeout);
} catch (Throwable ignored) {
return false;
boolean ping(String host)
Checks if the Host is Reachable
try {
 return InetAddress.getByName(host).isReachable(100);
} catch (IOException e) {
 return false;
boolean ping(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;
boolean ping(String host, int timeout)
ping
try {
 return InetAddress.getByName(host).isReachable(timeout);
} catch (Exception e) {
 return false;
void Ping(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);
...
boolean ping(String host, int timeout)
ping
InetAddress address = null;
try {
 address = InetAddress.getByName(host);
} catch (UnknownHostException e) {
 e.printStackTrace();
 return false;
boolean b = false;
...


AltStyle によって変換されたページ (->オリジナル) /