Electrofriends

Java program to display Local machines IP Address

by Ranjith | 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));
	}
}

Share and Enjoy:
  • Digg
  • Technorati
  • StumbleUpon
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Mixx
  • Yahoo! Buzz
  • LinkedIn
  • NewsVine
  • RSS
  • email
Similar Posts:

Leave a Reply

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya