Here you can find the source of ping(String host)
Parameter | Description |
---|---|
host | Hostname |
public static boolean ping(String host)
//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; } } }