Monday, June 21, 2010

How can check server is up or down using java

I have updated in http://www.freejavaclass.com/
InetAddress inet = null;

try
{
          inet = InetAddress.getByName("mail.google.com");
          System.out.println ("IP : " + inet.getHostAddress());
          if(inet.isReachable(1000))
         {
                System.out.println("Server is up");
         }
         else
         {
                System.out.println("Server is down");
         }
}

No comments:

Post a Comment

How can instantiate Java interface without implementing.

public interface Foo { String method(); } public class Claaa {    public static void main(String[] args) {     Foo fooByIC...