Javatpoint Logo
Javatpoint Logo

Java InetAddress getAllByName() method

The getAllByName() method of Java InetAddressGiven class returns an array of IP addresses, based on the given host name and the configured name service on the system. If the host is null then the InetAddress representing an address of the loopback interface is returned.

Syntax:

Parameters:

host - the name of host ,or null.

Returns

The getAllByName() method returns an array of all the IP address for the specified host name.

Throws

UnknownHostException - if no Ip address for the host could be found, or if 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 1

Test it Now

Output:

www.javatpoint.com/185.53.178.9

Example 2

Test it Now

Output:

1. [Ljava.net.InetAddress;@1540e19d

Next TopicInetAddress Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA