This example shows how to find the IP address of any hostname or a website. Below Java code uses getByName method from InetAddress class to resolve IP Address of given domain or host name.
1 2 3 4 5 6 7 8 9 10 11 12 |
import java.net.InetAddress; import java.net.UnknownHostException; public class MainClass { public static void main(String args[]) { try { InetAddress inetAddr = InetAddress.getByName("www.insecure.in"); System.out.println(inetAddr.toString()); } catch (UnknownHostException ex) { } } } |