Getting the hostname of an IP address in Java

The InetAddress Class is able to return the hostname given an IP.
Following app demonstrates the use:

import java.net.*;
 
public class Main
{
   public static void main(String [] args) {
      if (args.length != 1) {
         System.out.println("Usage: java Main <IP>");
         System.exit(1);
      }
 
      try {
         InetAddress inet = InetAddress.getByName(args[0]);
         System.out.println ("Hostname of " + args[0] + ": " + inet.getHostName());
      }
      catch(UnknownHostException e) {
         System.out.println(e);
      }
   }
}

Running it with

java Main 204.71.202.160

outputs:

Hostname of 204.71.202.160: w1.yahoo.com