Java InetAddress getByName() methodThe getByName() method of InetAddress class determines the IP address of a host from the given host's name. If the host name is null, then an InetAddress representing an address of the loopback interface is returned. Syntax:Parameters:host - the specified host, or null. ReturnsThe getByName() method returns an IP address for the given host name. ThrowsUnknownHostException: if no IP address for the host could be found, or if a scope_id was specified for a global IPv6 address. SecurityException: if a security manager exists and its checkConnect method doesn?t allow the operation. Example 1Test it NowOutput: 46.21.29.40 Example 2Test it NowOutput: localhost/127.0.0.1
Next TopicInetAddress Class
|