Java examples for Network:Ping
ping an Address
//package com.java2s; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; public class Main { @SuppressWarnings("resource") public static boolean ping(String address, int port) { InetSocketAddress isa = new InetSocketAddress(address, port); Socket connection = new Socket(); try {// www . j a v a 2 s .co m connection.connect(isa, 5 * 1000); } catch (IOException e) { return false; } return true; } }