Write a program to find out IP address of current system?

import java.net.InetAddress;

class IPFinder

{

      public static void main(String arg[])

      {

            try

            {

                  InetAddress address=InetAddress.getByName(arg[0]);

                  System.out.println("IP Address is "+address.getHostAddress());

            }

            catch(Exception e)

            {

                  System.out.println(e);

            }

      }

}

//java IPFinder localhost

//java IPFinder Vikrant-PC

IP Finder.PNG

, , , , , , ,

Leave a Reply