IP Ping
In this chapter you will learn:
Ping an IP address
java.net.InetAddress.isReachable(int)
can be used to check if a server is reachable or not.
import java.net.InetAddress;
// jav a 2s .c o m
public class Main {
public static void main(String[] argv) throws Exception {
InetAddress address = InetAddress.getByName("web.mit.edu");
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("Reach: " + address.isReachable(3000));
}
}
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » URL URI