Java Host Ping ping(final String host, final int timeout)

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

Description

ping

License

LGPL

Declaration

public static boolean ping(final String host, final int timeout) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.net.*;

public class Main {
    public static boolean ping(final String host, final int timeout) {
        try {//from  www. j a  v  a 2s .co m
            final InetAddress address = InetAddress.getByName(host);
            return address.isReachable(timeout);
        } catch (Throwable ignored) {
        }
        return false;
    }
}

Related

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