InetAddress GetCanonicalHostName() Example

Gets the fully qualified domain name for this IP address.


InetAddressclass GetCanonicalHostName() method example. This example shows you how to use GetCanonicalHostName() method.This method Gets the fully qualified domain name for this IP address.

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

import java.net.*;

public class GetCanonicalHostName {

    public static void main(String[] argsthrows UnknownHostException {
        InetAddress ia = InetAddress.getLocalHost();
        // Gets the fully qualified domain name for this IP address.
        String s = ia.getCanonicalHostName();
        System.out.println("domain name is: "+s);
    }
}

Output of the program:-
 domain name is: girish-desktop

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

HOME | COPYRIGHT | CONTACT US