Java Ping ping(String ip)

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

Description

ping

License

Open Source License

Declaration

public static boolean ping(String ip) 

Method Source Code

//package com.java2s;
import java.io.IOException;

public class Main {
    public static boolean ping(String ip) {
        try {// ww  w  . ja  va  2  s.  c  o m
            Process p = Runtime.getRuntime().exec("ping " + ip + " 1");
            return (p.waitFor() == 0);
        } catch (IOException e) {
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    }
}

Related

  1. pingHost(String host)
  2. ping(String url, int timeout)
  3. ping(String url, int timeout)
  4. pingHttp(URL url, int retry, int timeout)