Java Host Ping ping(String host, int timeout)

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

Description

ping

License

Open Source License

Declaration

public static boolean ping(String host, int timeout) 

Method Source Code


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

import java.net.InetAddress;

public class Main {
    public static boolean ping(byte[] ip, int timeout) {
        try {/*w  w  w.  jav a 2  s. c  o  m*/
            return InetAddress.getByAddress(ip).isReachable(timeout);
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean ping(String host, int timeout) {
        try {
            return InetAddress.getByName(host).isReachable(timeout);
        } catch (Exception e) {
            return false;
        }
    }
}

Related

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