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