This Java example shows how to Ping a Host or an IP Address or a Hostname of any computer system in the network or on the internet.
1 2 3 4 5 6 7 8 9 |
import java.net.InetAddress; public class Main { public static void main(String[] args) throws Exception { InetAddress address = InetAddress.getByName("17.16.15.14"); boolean reachable = address.isReachable(10000); System.out.println("Is host reachable? " + reachable); } } |