Java Host Ping ping(String host)

Here you can find the source of ping(String host)

Description

Checks if the Host is Reachable

License

Open Source License

Parameter

Parameter Description
host Hostname

Return

is reachable

Declaration

public static boolean ping(String host) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.net.InetAddress;

public class Main {
    /**//from  w  ww. j  av  a2 s  . co  m
     * Checks if the Host is Reachable
     *
     * @param host Hostname
     * @return is reachable
     */
    public static boolean ping(String host) {
        try {
            return InetAddress.getByName(host).isReachable(100);
        } catch (IOException e) {
            return false;
        }
    }
}

Related

  1. ping(final String host, final int timeout)
  2. ping(String host, int timeout)
  3. ping(String host, int timeout)
  4. Ping(String host, int timeout)
  5. ping(String host, int timeout)