In this section you will learn to
retrieve the information about the local host name using the getHostName()
method. Here is an example that provides the usage of
the getHostName() method in more detail.
Create a class "IPReverse". Call the InetAddress class and create a class object and pass the IP address in InetAddress.getByName() method. Now retrieve the Host name of the IP address what we are pass in getByName() method using the getHostName() method.
Here is the Code of the Example :
The above example shows the host name of the IP address what ever we pass in the getByName() method. The output of the above example is as under, where the hostname shows as TEST1.
Here is the Output of the Example :
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: April 17, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles