Java InetAddress.getByName(String host)

Syntax

InetAddress.getByName(String host) has the following syntax.

public static InetAddress getByName(String host)    throws UnknownHostException

Example

In the following code shows how to use InetAddress.getByName(String host) method.


//  www.  j a va2 s  . c o  m
import java.net.InetAddress;

public class Main {

  public static void main(String[] args) {

    try {
      InetAddress ia = InetAddress.getByName("64.21.29.37");
      System.out.println(ia.getHostName());
    } catch (Exception ex) {
      System.err.println(ex);
    }

  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.net »




CookieManager
CookiePolicy
CookieStore
DatagramPacket
DatagramSocket
HttpCookie
HttpURLConnection
InetAddress
JarURLConnection
MulticastSocket
ServerSocket
Socket
SocketAddress
URI
URL
URLConnection
URLDecoder
URLEncoder