- java.lang.Object
-
- io.netty5.resolver.HostsFileParser
-
public final class HostsFileParser extends Object
A parser for hosts files. The produced mappings contain only the first entry per hostname. Consider usingHostsFileEntriesProvider
when mappings with all entries per hostname are needed.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HostsFileEntries
parse()
Parse hosts file at standard OS location using the system defaultCharset
for decoding.static HostsFileEntries
parse(File file)
Parse a hosts file using the system defaultCharset
for decoding.static HostsFileEntries
parse(File file, Charset... charsets)
Parse a hosts file.static HostsFileEntries
parse(Reader reader)
Parse a reader of hosts file format.static HostsFileEntries
parseSilently()
Parse hosts file at standard OS location using the systems defaultCharset
for decoding.static HostsFileEntries
parseSilently(Charset... charsets)
Parse hosts file at standard OS location using the givenCharset
s one after each other until we were able to parse something or none is left.
-
-
-
Method Detail
-
parseSilently
public static HostsFileEntries parseSilently()
Parse hosts file at standard OS location using the systems defaultCharset
for decoding.- Returns:
- a
HostsFileEntries
-
parseSilently
public static HostsFileEntries parseSilently(Charset... charsets)
Parse hosts file at standard OS location using the givenCharset
s one after each other until we were able to parse something or none is left.- Parameters:
charsets
- theCharset
s to try as file encodings when parsing.- Returns:
- a
HostsFileEntries
-
parse
public static HostsFileEntries parse() throws IOException
Parse hosts file at standard OS location using the system defaultCharset
for decoding.- Returns:
- a
HostsFileEntries
- Throws:
IOException
- file could not be read
-
parse
public static HostsFileEntries parse(File file) throws IOException
Parse a hosts file using the system defaultCharset
for decoding.- Parameters:
file
- the file to be parsed- Returns:
- a
HostsFileEntries
- Throws:
IOException
- file could not be read
-
parse
public static HostsFileEntries parse(File file, Charset... charsets) throws IOException
Parse a hosts file.- Parameters:
file
- the file to be parsedcharsets
- theCharset
s to try as file encodings when parsing.- Returns:
- a
HostsFileEntries
- Throws:
IOException
- file could not be read
-
parse
public static HostsFileEntries parse(Reader reader) throws IOException
Parse a reader of hosts file format.- Parameters:
reader
- the file to be parsed- Returns:
- a
HostsFileEntries
- Throws:
IOException
- file could not be read
-
-