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[] args) throws 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 |
|