Java program to display Local machines IP Address

Friday, April 30th, 2010

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));
	}
}
Avatar Image

Author Name :
Ranjith

Total : 1 Comment


1 Response to Java program to display Local machines IP Address

  1. Inter Milan Jersey 2011 2012

    where to buy Premier and Stitched Chicago Bears jerseys ??…

    [...]we adivce go to this website to see more about Chicago Bears jerseys and others. [...]…

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup