IP Ping

In this chapter you will learn:

  1. How to ping an IP address

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:

  1. How to use NetworkInterface class
  2. How to get MAC address
Home » Java Tutorial » URL URI
URL
URL Creation
URL for jar file
URL Components
Convert file path to URL
URL Relative
URL Protocol
Read from URL
Compare URL
URLConnection
HTTP Header
URLConnection Post
Cookie
URLConnection Read
HttpURLConnection
HttpURLConnection Properties
HttpURLConnection proxy
HttpURLConnection Authenticator
HTTPS
JarURLConnection
Encode a URL
Decode a URL
URI
URI Normalization
URI Resolution
URI Relativization
Convert URI to URL
IP Address
IP Ping
NetworkInterface