0

ドメインが存在するかどうかを確認したいので、ここに私のコードがあります:

try {
    InetAddress inetAddress = InetAddress.getByName("ouestfrance-ecole.com");
    System.out.println(inetAddress.getHostName());
    System.out.println(inetAddress.getHostAddress());
} catch (UnknownHostException e) {
    e.printStackTrace();
}

そして、応答は次のとおりです。

java.net.UnknownHostException: ouestfrance-ecole.com
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:849)
at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1202)
at java.net.InetAddress.getAllByName0(InetAddress.java:1153)
at java.net.InetAddress.getAllByName(InetAddress.java:1083)
at java.net.InetAddress.getAllByName(InetAddress.java:1019)
at java.net.InetAddress.getByName(InetAddress.java:969)
at MainApp.main(MainApp.java:18)

しかし、ブラウザーに ouestfrance-ecole.com を入力するか実行するhost ouestfrance-ecole.comと、ドメインが実際に存在し、Web サイトをホストする応答が返されます。

理由は何ですか?

ありがとう

4

1 に答える 1

0
InetAddress.getByName("www.ouestfrance-ecole.com")

正常に動作します (サブドメインに注意してwwwください)。ouestfrance-ecole.com動作しないのは(私のブラウザでも)です。

于 2013-02-09T20:32:58.183 に答える