public final class HostsFileParser extends Object
/etc/hosts. The
cache is cleared when the file is modified.| Constructor and Description |
|---|
HostsFileParser()
Creates a new instance based on the current OS's default.
|
HostsFileParser(Path path)
Creates an instance with a custom hosts database path.
|
HostsFileParser(Path path,
boolean clearCacheOnChange)
Creates an instance with a custom hosts database path.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<InetAddress> |
getAddressForHost(Name name,
int type)
Performs on-demand parsing and caching of the local hosts database.
|
public HostsFileParser()
/etc/hosts, while on Windows %SystemRoot%\System32\drivers\etc\hosts is used. The cache is cleared when the file has
changed.public HostsFileParser(Path path)
path - The path to the hosts database.public HostsFileParser(Path path, boolean clearCacheOnChange)
path - The path to the hosts database.clearCacheOnChange - set to true to clear the cache when the hosts file changes.public Optional<InetAddress> getAddressForHost(Name name, int type) throws IOException
name - the hostname to search for.type - Record type to search for, see Type.IOException - When the parsing fails.IllegalArgumentException - when type is not Type.A orType.AAAA.Copyright © 2021 dnsjava.org. All rights reserved.