Class HostsFileParser

java.lang.Object
io.netty.resolver.HostsFileParser

public final class HostsFileParser extends java.lang.Object
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

    Constructors
    Modifier
    Constructor
    Description
    private
    Can't be instantiated.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static HostsFileEntries
     
    Parse hosts file at standard OS location using the system default Charset for decoding.
    parse(java.io.File file)
    Parse a hosts file using the system default Charset for decoding.
    parse(java.io.File file, java.nio.charset.Charset... charsets)
    Parse a hosts file.
    parse(java.io.Reader reader)
    Parse a reader of hosts file format.
    Parse hosts file at standard OS location using the systems default Charset for decoding.
    parseSilently(java.nio.charset.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.
    private static java.util.Map<java.lang.String, ?>
    toMapWithSingleValue(java.util.Map<java.lang.String, java.util.List<java.net.InetAddress>> fromMapWithListValue)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HostsFileParser

      private HostsFileParser()
      Can't be instantiated.
  • Method Details

    • parseSilently

      public static HostsFileEntries parseSilently()
      Parse hosts file at standard OS location using the systems default Charset for decoding.
      Returns:
      a HostsFileEntries
    • parseSilently

      public static HostsFileEntries parseSilently(java.nio.charset.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 - the Charsets 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 default Charset for 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 default Charset for 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 parsed
      charsets - the Charsets 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
    • hostsFileEntries

      private static HostsFileEntries hostsFileEntries(HostsFileEntriesProvider provider)
    • toMapWithSingleValue

      private static java.util.Map<java.lang.String, ?> toMapWithSingleValue(java.util.Map<java.lang.String, java.util.List<java.net.InetAddress>> fromMapWithListValue)