Programming Tips - How can I resolve a DNS address into an IP-address?

Date: 2015may15 Language: Java Keywords: lookup Q. How can I resolve a DNS address into an IP-address? A. use InetAddress.getByName() like this:
import java.net.InetAddress; import java.net.UnknownHostException; String lookupHostIp(final String host) { String address = null; try { InetAddress a = java.net.InetAddress.getByName(host); address = a.getHostAddress(); } catch (UnknownHostException e) { address = "0.0.0.0"; } return address; }