Get All addresses by name : Internet Addresses « Network « Java Tutorial






import java.net.*;

public class MainClass {

  public static void main (String[] args) {

    try {
      InetAddress[] addresses = InetAddress.getAllByName("www.google.com");
      for (int i = 0; i < addresses.length; i++) {
        System.out.println(addresses[i]);
      }
    }
    catch (UnknownHostException e) {
      System.out.println("Could not find www.apple.com");
    }

  }

}
www.google.com/72.14.253.147
www.google.com/72.14.253.99
www.google.com/72.14.253.103
www.google.com/72.14.253.104








19.7.Internet Addresses
19.7.1.Get my own address
19.7.2.Create InetAddress by Name
19.7.3.Get Host name from InetAddress
19.7.4.Get local host from InetAddress
19.7.5.Get All addresses by name
19.7.6.Compare two InetAddresses
19.7.7.Getting the IP Address of a Hostname
19.7.8.java.net.InetAddress.isReachable(int) can be used to check if a server is reachable or not.
19.7.9.Translate host names to Internet addresses
19.7.10.Get canonical host name
19.7.11.Ping a host