Sunday 18 January 2015

Java Program to Find IP Address of the Machine


                    Java Program to find IP Address of the Machine



import java.net.InetAddress;
import java.net.UnknownHostException;


public class FindIpAddress {

  /**
   * @param args
   */
  public static void main(String[] args) {
    
     
              InetAddress myIp = null;
        try {
          myIp = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
          System.out.println("Exception caught ="+e.getMessage());
        }
              System.out.println("IP of my system is := "+myIp.getHostAddress());
       
  }

}













Enjoy Reading.

No comments:

Post a Comment