public interface InetAddressResolver
InetAddress
delegates all lookup operations to the system-wide resolver. The system-wide resolver can be customized by deploying an implementation of InetAddressResolverProvider
.
Modifier and Type | Interface | Description |
---|---|---|
static final class |
InetAddressResolver.LookupPolicy |
A LookupPolicy object describes characteristics that can be applied to a lookup operation. |
Modifier and Type | Method | Description |
---|---|---|
String |
lookupByAddress |
Lookup the host name corresponding to the raw IP address provided. |
Stream |
lookupByName |
Given the name of a host, returns a stream of IP addresses of the requested address family associated with a provided hostname. |
Stream<InetAddress> lookupByName(String host, InetAddressResolver.LookupPolicy lookupPolicy) throws UnknownHostException
host
should be a machine name, such as "www.example.com
", not a textual representation of its IP address. No validation is performed on the given host
name: if a textual representation is supplied, the name resolution is likely to fail and UnknownHostException
may be thrown.
The address family type and addresses order are specified by the LookupPolicy
instance. Lookup operation characteristics could be acquired with InetAddressResolver.LookupPolicy.characteristics()
. If InetAddressResolver.LookupPolicy.IPV4
and InetAddressResolver.LookupPolicy.IPV6
characteristics provided then this method returns addresses of both IPV4 and IPV6 families.
host
- the specified hostnamelookupPolicy
- the address lookup policyNullPointerException
- if either parameter is null
UnknownHostException
- if no IP address for the host
could be foundString lookupByAddress(byte[] addr) throws UnknownHostException
addr
argument is in network byte order: the highest order byte of the address is in addr[0]
.
IPv4 address byte array must be 4 bytes long and IPv6 byte array must be 16 bytes long.
addr
- byte array representing a raw IP addressString
representing the host name mappingUnknownHostException
- 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 is null
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/spi/InetAddressResolver.html