Here you can find the source of getIpAddress(String server)
Parameter | Description |
---|---|
server | the hostname to convert to an ip address. |
public static String getIpAddress(String server)
//package com.java2s; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//w w w.j av a2 s .co m * Perform a lookup of server returning the associated ip address. * DNS must be enabled for this call to succeed. * * @param server the hostname to convert to an ip address. * @return String the ipAddress for the speceified server. null if * the lookup of the server failed and the ip address can not be determined. */ public static String getIpAddress(String server) { if (server == null) return null; try { InetAddress addr = InetAddress.getByName(server); return addr.getHostAddress(); } catch (UnknownHostException uhe) { return null; } } }