InetAddress GetHostName() Example

Gets the host name for this IP address.


InetAddressclass GetHostName() method example. This example shows you how to use GetHostName() method.This method Gets the host name for this IP address.

Here is the code:-
/* 
 * @Program that Gets the host name for this IP address.
 * GetHostName.java 
 * Author:-RoseIndia Team
 * Date:-19-Jun-2008
 */

import java.net.*;
public class GetHostName {
public static void main(String[] argsthrows UnknownHostException{
InetAddress ia = InetAddress.getLocalHost();
//Gets the host name for this IP address.
String s=ia.getHostName();
System.out.println("Hostname for this IP address is: "+s);

    }
}

Output of the program:-
Hostname for this IP address is: girish-desktop

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

HOME | COPYRIGHT | CONTACT US