Package net.bjmsw.hda.vs.helper
Class Config
java.lang.Object
net.bjmsw.hda.vs.helper.Config
The Config class represents a configuration manager that loads and retrieves properties from a configuration file.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) FileThe configFile variable represents the configuration file that the Config class uses to load and retrieve properties. -
Constructor Summary
ConstructorsConstructorDescriptionConfig()Represents a configuration object that loads and retrieves configuration properties from a config file. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidThis method creates a config file by copying a pre-existing config.properties file from the resources directory to the project root.getProperty(String key) Retrieves the value of the property with the specified key from the config file.
-
Field Details
-
configFile
File configFileThe 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
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
-