Tuesday, January 20, 2015

Determine Local IP Address in java pgm



Determine Local IP Address

import java.net.InetAddress;
public class Main
 {
   public static void main(String[] args) throws Exception
  {
      InetAddress addr = InetAddress.getLocalHost();
      System.out.println("Local HostAddress: "+addr.getHostAddress());
      String hostname = addr.getHostName();
      System.out.println("Local host name: "+hostname);
   }
}

No comments:

Post a Comment