Program : To display Local machines IP Address
By : Kapil Lohia
import java.net.*;
import java.io.*;
public class ip_localmachine
{
public static void main(String args[]) throws Exception
{
InetAddress ipadd =InetAddress.getLocalHost();
System.out.println("Host and Address :"+ipadd);
System.out.println("Host name :"+ipadd.getHostName());
String n=ipadd.toString();
System.out.println("IP address :"+n.substring(n.indexOf("/")+1));
}
} |
import java.net.*;
import java.io.*;
public class ip_localmachine
{
public static void main(String args[]) throws Exception
{
InetAddress ipadd =InetAddress.getLocalHost();
System.out.println("Host and Address :"+ipadd);
System.out.println("Host name :"+ipadd.getHostName());
String n=ipadd.toString();
System.out.println("IP address :"+n.substring(n.indexOf("/")+1));
}
}
Editorial Team
We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.