import java.net.InetAddress;Output:
import java.net.SocketException;
import java.net.UnknownHostException;
public class ServerAddress {
public static void main(String[] zero) throws SocketException {
InetAddress ServerAddress;
try{
ServerAddress= InetAddress.getByName("www.yahoo.fr");
//domain name
System.out.println("Yahoo server address = "+
ServerAddress.getHostName());
//Yahoo server IP address
System.out.println("Domain name = "+
ServerAddress.getHostName());
System.out.println("The IP address of the server Yahoo.com = "+
ServerAddress.getHostAddress());
System.out.println("The IP address of the server Yahoo.fr = "+
InetAddress.getByName("www.yahoo.fr").getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
domain name = www.yahoo.comgetHostName(): returns the machine name for this IP address.
The IP address of the server Yahoo.com = 46.228.47.115
The IP address of the server Yahoo.fr = 77.238.184.150
Please disable your ad blocker and refresh the window to use this website.