Class ConfigReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ConfigReader
    extends java.lang.Object
    implements java.io.Closeable
    Reader for parsing Config out of file-lines.

    ConfigReader can read a single file at a time, so it is NOT thread safe.

    • Constructor Summary

      Constructors 
      Constructor Description
      ConfigReader​(java.io.BufferedReader bufferedReader)
      Create a new ConfigReader for a BufferedReader.
      ConfigReader​(java.io.InputStream in)
      Create a new ConfigReader for an InputStream.
      ConfigReader​(java.nio.file.Path filePath)
      Create a new ConfigReader for a Path.
      ConfigReader​(java.util.Scanner scanner)
      Create a new ConfigReader for a Scanner.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      Config read()
      Read the resource into a Config.
      • Methods inherited from class java.lang.Object

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

      • ConfigReader

        public ConfigReader​(java.nio.file.Path filePath)
                     throws java.io.IOException
        Create a new ConfigReader for a Path.
        Parameters:
        filePath - Path to a config file.
        Throws:
        java.io.IOException - If the path can not be read.
      • ConfigReader

        public ConfigReader​(java.io.InputStream in)
        Create a new ConfigReader for an InputStream.
        Parameters:
        in - InputStream of a resource that is a config.
      • ConfigReader

        public ConfigReader​(java.io.BufferedReader bufferedReader)
        Create a new ConfigReader for a BufferedReader.
        Parameters:
        bufferedReader - BufferedReader of a resource that is a config.
      • ConfigReader

        public ConfigReader​(java.util.Scanner scanner)
        Create a new ConfigReader for a Scanner.
        Parameters:
        scanner - Scanner of a resource that is a config.
    • Method Detail

      • read

        public Config read()
        Read the resource into a Config.
        Returns:
        Config parsed from the lines found in the given resource.
        Throws:
        java.lang.IllegalStateException - If the configReader is closed by calling close()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable