Getting the IP address of a host in Java

The InetAddress class is able to map between hostnames and IP addresses.
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 <URL>");
         System.exit(1);
      }
 
      try {
         InetAddress inet = InetAddress.getByName(args[0]);
         System.out.println ("IP of " + args[0] + ": " + inet.getHostAddress());
      }
      catch(UnknownHostException e) {
         System.out.println(e);
      }
   }
}

Running it with

java Main www.yahoo.com

outputs:

IP of www.esus.com: 204.71.202.160