Here you can find the source of getIpByHost(String hostName)
Parameter | Description |
---|---|
hostName | a parameter |
public static String getIpByHost(String hostName)
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { /**/* w w w . j a va2s. com*/ * @param hostName * @return ip address or hostName if UnknownHostException */ public static String getIpByHost(String hostName) { try { return InetAddress.getByName(hostName).getHostAddress(); } catch (UnknownHostException e) { return hostName; } } }