InetAddress GetHostAddress() Example

Returns the IP address string in textual presentation.


InetAddressclass GetHostAddress() method example. This example shows you how to use GetHostAddress() method.This method Returns the IP address string in textual presentation.

Here is the code:-
/* 
 * @Program that Returns the IP address string in textual presentation.
 * GetHostAddress.java 
 * Author:-RoseIndia Team
 * Date:-19-Jun-2008
 */

import java.net.*;

public class GetHostAddress {
public static void main(String[] argsthrows UnknownHostException {
 InetAddress ia = InetAddress.getLocalHost();
 //Returns the IP address string in textual presentation.
 String s=ia.getHostAddress();
 System.out.println("IP address is : "+s);
    }
}

Output of the program:-
 IP address is : 127.0.1.1

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US