Top Description Constructors Methods
io.netty5.resolver

public final Class HostsFileParser

extends Object
Class Inheritance
Imports
java.io.File, .IOException, .Reader, java.net.Inet4Address, .Inet6Address, .InetAddress, java.nio.charset.Charset, java.util.HashMap, .List, .Map

A parser for hosts files. The produced mappings contain only the first entry per hostname. Consider using HostsFileEntriesProvider when mappings with all entries per hostname are needed.

Constructor Summary

AccessConstructor and Description
private
HostsFileParser()

Can't be instantiated.

Method Summary

Modifier and TypeMethod and Description
private static HostsFileEntries
public static HostsFileEntries

Returns:

a HostsFileEntries
parse
()

Parse hosts file at standard OS location using the system default Charset for decoding.

public static HostsFileEntries

Returns:

a HostsFileEntries
parse
(File
the file to be parsed
file
)

Parse a hosts file using the system default Charset for decoding.

public static HostsFileEntries

Returns:

a HostsFileEntries
parse
(File
the file to be parsed
file
,
Charset...
the Charsets to try as file encodings when parsing.
charsets
)

Parse a hosts file.

public static HostsFileEntries

Returns:

a HostsFileEntries
parse
(Reader
the file to be parsed
reader
)

Parse a reader of hosts file format.

public static HostsFileEntries

Returns:

a HostsFileEntries
parseSilently
()

Parse hosts file at standard OS location using the systems default Charset for decoding.

public static HostsFileEntries

Returns:

a HostsFileEntries
parseSilently
(Charset...
the Charsets to try as file encodings when parsing.
charsets
)

Parse hosts file at standard OS location using the given Charsets one after each other until we were able to parse something or none is left.

private static Map<String, ?>
toMapWithSingleValue(Map<String, List<InetAddress>> fromMapWithListValue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HostsFileParserback to summary
private HostsFileParser()

Can't be instantiated.

Method Detail

hostsFileEntriesback to summary
private static HostsFileEntries hostsFileEntries(HostsFileEntriesProvider provider)
Annotations
@SuppressWarnings:unchecked
parseback to summary
public static HostsFileEntries parse() throws IOException

Parse hosts file at standard OS location using the system default Charset for decoding.

Returns:HostsFileEntries

a HostsFileEntries

Exceptions
IOException:
file could not be read
parseback to summary
public static HostsFileEntries parse(File file) throws IOException

Parse a hosts file using the system default Charset for decoding.

Parameters
file:File

the file to be parsed

Returns:HostsFileEntries

a HostsFileEntries

Exceptions
IOException:
file could not be read
parseback to summary
public static HostsFileEntries parse(File file, Charset... charsets) throws IOException

Parse a hosts file.

Parameters
file:File

the file to be parsed

charsets:Charset[]

the Charsets to try as file encodings when parsing.

Returns:HostsFileEntries

a HostsFileEntries

Exceptions
IOException:
file could not be read
parseback to summary
public static HostsFileEntries parse(Reader reader) throws IOException

Parse a reader of hosts file format.

Parameters
reader:Reader

the file to be parsed

Returns:HostsFileEntries

a HostsFileEntries

Exceptions
IOException:
file could not be read
parseSilentlyback to summary
public static HostsFileEntries parseSilently()

Parse hosts file at standard OS location using the systems default Charset for decoding.

Returns:HostsFileEntries

a HostsFileEntries

parseSilentlyback to summary
public static HostsFileEntries parseSilently(Charset... charsets)

Parse hosts file at standard OS location using the given Charsets one after each other until we were able to parse something or none is left.

Parameters
charsets:Charset[]

the Charsets to try as file encodings when parsing.

Returns:HostsFileEntries

a HostsFileEntries

toMapWithSingleValueback to summary
private static Map<String, ?> toMapWithSingleValue(Map<String, List<InetAddress>> fromMapWithListValue)