Package io.netty.resolver
Class HostsFileParser
- java.lang.Object
-
- io.netty.resolver.HostsFileParser
-
public final class HostsFileParser extends java.lang.ObjectA parser for hosts files. The produced mappings contain only the first entry per hostname. Consider usingHostsFileEntriesProviderwhen mappings with all entries per hostname are needed.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HostsFileEntriesparse()Parse hosts file at standard OS location using the system defaultCharsetfor decoding.static HostsFileEntriesparse(java.io.File file)Parse a hosts file using the system defaultCharsetfor decoding.static HostsFileEntriesparse(java.io.File file, java.nio.charset.Charset... charsets)Parse a hosts file.static HostsFileEntriesparse(java.io.Reader reader)Parse a reader of hosts file format.static HostsFileEntriesparseSilently()Parse hosts file at standard OS location using the systems defaultCharsetfor decoding.static HostsFileEntriesparseSilently(java.nio.charset.Charset... charsets)Parse hosts file at standard OS location using the givenCharsets 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 defaultCharsetfor decoding.- Returns:
- a
HostsFileEntries
-
parseSilently
public static HostsFileEntries parseSilently(java.nio.charset.Charset... charsets)
Parse hosts file at standard OS location using the givenCharsets one after each other until we were able to parse something or none is left.- Parameters:
charsets- theCharsets to try as file encodings when parsing.- Returns:
- a
HostsFileEntries
-
parse
public static HostsFileEntries parse() throws java.io.IOException
Parse hosts file at standard OS location using the system defaultCharsetfor decoding.- Returns:
- a
HostsFileEntries - Throws:
java.io.IOException- file could not be read
-
parse
public static HostsFileEntries parse(java.io.File file) throws java.io.IOException
Parse a hosts file using the system defaultCharsetfor decoding.- Parameters:
file- the file to be parsed- Returns:
- a
HostsFileEntries - Throws:
java.io.IOException- file could not be read
-
parse
public static HostsFileEntries parse(java.io.File file, java.nio.charset.Charset... charsets) throws java.io.IOException
Parse a hosts file.- Parameters:
file- the file to be parsedcharsets- theCharsets to try as file encodings when parsing.- Returns:
- a
HostsFileEntries - Throws:
java.io.IOException- file could not be read
-
parse
public static HostsFileEntries parse(java.io.Reader reader) throws java.io.IOException
Parse a reader of hosts file format.- Parameters:
reader- the file to be parsed- Returns:
- a
HostsFileEntries - Throws:
java.io.IOException- file could not be read
-
-