Class Config

java.lang.Object
net.bjmsw.hda.vs.helper.Config

public class Config extends Object
The Config class represents a configuration manager that loads and retrieves properties from a configuration file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) File
    The configFile variable represents the configuration file that the Config class uses to load and retrieve properties.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Represents a configuration object that loads and retrieves configuration properties from a config file.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    This method creates a config file by copying a pre-existing config.properties file from the resources directory to the project root.
    Retrieves the value of the property with the specified key from the config file.

    Methods inherited from class java.lang.Object

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

    • configFile

      File configFile
      The configFile variable represents the configuration file that the Config class uses to load and retrieve properties.

      It is an instance of the File class and is initialized with the path to the config.properties file.

      The configFile variable is used in the following methods of the Config class: - createConfigFile: This method copies the config.properties file from the resources folder to the project root folder, where it is stored as a File object. - getProperty: This method loads the properties from the configFile and retrieves the value for a specified key.

  • Constructor Details

    • Config

      public Config()
      Represents a configuration object that loads and retrieves configuration properties from a config file.
  • Method Details

    • createConfigFile

      private void createConfigFile()
      This method creates a config file by copying a pre-existing config.properties file from the resources directory to the project root. If the file does not exist in the resources directory, it creates a new config file with default values.
    • getProperty

      public String getProperty(String key)
      Retrieves the value of the property with the specified key from the config file. Loads the properties each time this method is called.
      Parameters:
      key - the key of the property to retrieve
      Returns:
      the value of the property, or null if the property does not exist or an error occurs while reading the config file