code: public static String normalizeHostName(String name) {
      try {
        return InetAddress.getByName(name).getHostAddress();
      } catch (UnknownHostException e) {
        return name;
      }
    }
docs: Given a string representation of a host, return its ip address
  in textual presentation.
  
  @param name a string representation of a host:
  either a textual representation its IP address or its host name
  @return its IP address in the string format