Class ResolvConf


  • final class ResolvConf
    extends java.lang.Object
    Looks up the nameservers from the /etc/resolv.conf file, intended for Linux and macOS.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.net.InetSocketAddress> nameservers  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ResolvConf​(java.io.BufferedReader reader)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static ResolvConf fromFile​(java.lang.String file)
      Reads the given file and extracts the nameservers using the syntax of the /etc/resolv.conf file, see man resolv.conf.
      (package private) static ResolvConf fromReader​(java.io.BufferedReader reader)
      Reads from the given reader and extracts the nameservers using the syntax of the /etc/resolv.conf file, see man resolv.conf.
      (package private) java.util.List<java.net.InetSocketAddress> getNameservers()  
      (package private) static ResolvConf system()
      Returns the nameservers from the /etc/resolv.conf file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nameservers

        private final java.util.List<java.net.InetSocketAddress> nameservers
    • Constructor Detail

      • ResolvConf

        private ResolvConf​(java.io.BufferedReader reader)
                    throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • fromReader

        static ResolvConf fromReader​(java.io.BufferedReader reader)
                              throws java.io.IOException
        Reads from the given reader and extracts the nameservers using the syntax of the /etc/resolv.conf file, see man resolv.conf.
        Parameters:
        reader - contents of resolv.conf are read from this BufferedReader, up to the caller to close it
        Throws:
        java.io.IOException
      • fromFile

        static ResolvConf fromFile​(java.lang.String file)
                            throws java.io.IOException
        Reads the given file and extracts the nameservers using the syntax of the /etc/resolv.conf file, see man resolv.conf.
        Throws:
        java.io.IOException
      • system

        static ResolvConf system()
        Returns the nameservers from the /etc/resolv.conf file. The file is only read once during the lifetime of this class.
      • getNameservers

        java.util.List<java.net.InetSocketAddress> getNameservers()