InetAddress Class
Package: java.net
The InetAddress class represents an IP address. It includes several useful methods that let you create InetAddress objects from strings that represent IP addresses or host names, or perform useful lookups to find out the IP address for a given host name (or vice versa).
The InetAddress class doesn’t have a constructor. Instead, the typical way to create it is to call one of its static methods, such as getByName.
Methods
|
Method |
Description |
|
|
Returns the raw IP address as an array of bytes. |
|
|
Returns an array of Internet addresses for the specified host name. This method performs a DNS query to get the addresses. It throws |
|
|
Returns the Internet address for the specified host name or IP address. This method performs a DNS query to get the address. It throws |
|
|
Returns the fully qualified host name for this IP address. |
|
|
Returns the IP address as a formatted string. |
|
|
Performs a reverse DNS lookup to get the host name for this IP address. |
|
|
Determines whether the IP address can be reached. The attempt fails if no response is reached before the timeout period (in milliseconds) ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access