JAVA-MANI.BLOGSPOT.COM
Monday, September 15, 2008
Since Java 1.5 (Tiger) the InetAddress class introduces an isReachable() method that can be use to ping or check if the address specified by the InetAddress is reachable.



import java.net.InetAddress;

public class PingExample
{
public static void main(String[] args)
{
try
{
InetAddress address = InetAddress.getByName("172.16.2.0");

// Try to reach the specified address within the timeout
// periode. If during this periode the address cannot be
// reach then the method returns false.
boolean reachable = address.isReachable(10000);

System.out.println("Is host reachable? " + reachable);
} catch (Exception e)
{
e.printStackTrace();
}
}
}

0 comments:

SUBSCRIBE VIA eMAIL

Enter your email address:

Delivered by FeedBurner

Recent Posts

Firefox 3

Counter

internet companies

Live Traffic Map

Subscribe Now