I am trying to use InetAddress to to return the IP address of a website name that the user enters, but I get an error at the statement: InetAddress ip = new InetAddress.getByName(site); The error shown is :
InetAddress.getByName cannot be resolved to a type
My code :
import java.util.*;
import java.net.*;
import java.io.*;
import java.net.InetAddress;
public class getIP {
public static void main(String args[])throws UnknownHostException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String site;
System.out.println("Enter the url :");
site = br.readLine();
try
{
InetAddress ip = new InetAddress.getByName(site);
}
catch(UnknownHostException ee)
{
System.out.println("Website not found.");
}
}
}