InetAddress delegates all lookup operations to the system-wide
resolver.
The system-wide resolver can be customized by
deploying an implementation of InetAddressResolverProvider.
- Since:
- 18
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classALookupPolicyobject describes characteristics that can be applied to a lookup operation. -
Method Summary
Modifier and TypeMethodDescriptionlookupByAddress(byte[] addr) Lookup the host name corresponding to the raw IP address provided.lookupByName(String host, InetAddressResolver.LookupPolicy lookupPolicy) Given the name of a host, returns a stream of IP addresses of the requested address family associated with a provided hostname.
-
Method Details
-
lookupByName
Stream<InetAddress> lookupByName(String host, InetAddressResolver.LookupPolicy lookupPolicy) throws UnknownHostException Given the name of a host, returns a stream of IP addresses of the requested address family associated with a provided hostname.hostshould be a machine name, such as "www.example.com", not a textual representation of its IP address. No validation is performed on the givenhostname: if a textual representation is supplied, the name resolution is likely to fail andUnknownHostExceptionmay be thrown.The address family type and addresses order are specified by the
LookupPolicyinstance. Lookup operation characteristics could be acquired withInetAddressResolver.LookupPolicy.characteristics(). IfInetAddressResolver.LookupPolicy.IPV4andInetAddressResolver.LookupPolicy.IPV6characteristics provided then this method returns addresses of both IPV4 and IPV6 families.- Parameters:
host- the specified hostnamelookupPolicy- the address lookup policy- Returns:
- a stream of IP addresses for the requested host
- Throws:
NullPointerException- if either parameter isnullUnknownHostException- if no IP address for thehostcould be found- See Also:
-
lookupByAddress
Lookup the host name corresponding to the raw IP address provided.addrargument is in network byte order: the highest order byte of the address is inaddr[0].IPv4 address byte array must be 4 bytes long and IPv6 byte array must be 16 bytes long.
- Parameters:
addr- byte array representing a raw IP address- Returns:
Stringrepresenting the host name mapping- Throws:
UnknownHostException- if no host name is found for the specified IP addressIllegalArgumentException- if the length of the provided byte array doesn't correspond to a valid IP address lengthNullPointerException- if addr isnull
-