InetAddress: getAllByName(String name)

 
import java.net.InetAddress;

public class MainClass {

  public static void main(String args[]) {
    try {

      // Get an address
      InetAddress ias[] = InetAddress.getAllByName("www.google.com");
      for (int i = 0; i < ias.length; i++) {
        System.out.println(ias[i].getHostName());
        System.out.println(ias[i].getHostAddress());
        byte bytes[] = ias[i].getAddress();
        for (int j = 0; j < bytes.length; j++) {
          if (j > 0)
            System.out.print(".");
          if (bytes[j] >= 0)
            System.out.print(bytes[j]);
          else
            System.out.print(bytes[j] + 256);
        }
        System.out.println("");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
  
Home 
  Java Book 
    Networking  

InetAddress:
  1. InetAddress
  2. InetAddress: getAllByName(String name)
  3. InetAddress: getByName(String host)
  4. InetAddress: getCanonicalHostName()
  5. InetAddress: getHostAddress()
  6. InetAddress: getHostName()
  7. InetAddress: getLocalHost()
  8. InetAddress: isReachable(int timeout)