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");
//ドメイン名
System.out.println("Yahoo server address = "+
ServerAddress.getHostName());
//Yahoo サーバーの IP アドレス
System.out.println("Domain name = "+
ServerAddress.getHostName());
System.out.println("サーバのIPアドレス Yahoo.com = "+
ServerAddress.getHostAddress());
System.out.println("サーバーのIPアドレス Yahoo.fr = "+
InetAddress.getByName("www.yahoo.fr").getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
domain name = www.yahoo.comgetHostName(): この IP アドレスのマシン名を返します。
サーバーのIPアドレス Yahoo.com = 46.228.47.115
サーバーのIPアドレス Yahoo.fr = 77.238.184.150
Please disable your ad blocker and refresh the window to use this website.