Class PropertiesFile

java.lang.Object
com.github.ngoanh2n.PropertiesFile

@ParametersAreNonnullByDefault public class PropertiesFile extends Object
Read properties file.

Repository:
Since:
2019
  • Constructor Details

    • PropertiesFile

      public PropertiesFile(String resourceName)
      Construct a new PropertiesFile by a resource name.
      Parameters:
      resourceName - The properties file name in resources dir to read.
    • PropertiesFile

      public PropertiesFile(String resourceName, boolean assignToSystem)
      Construct a new PropertiesFile by a resource name.
      Parameters:
      resourceName - The properties file name in resources dir to read.
      assignToSystem - Indicate to set all properties in file to system.
    • PropertiesFile

      public PropertiesFile(File file)
      Construct a new PropertiesFile by a File.
      Parameters:
      file - The properties file to read.
    • PropertiesFile

      public PropertiesFile(File file, boolean assignToSystem)
      Construct a new PropertiesFile by a File.
      Parameters:
      file - The properties file to read.
      assignToSystem - Indicate to set all properties in file to system.
  • Method Details

    • getProperty

      public String getProperty(String name)
      Get the value of property by name.
      Priority order: JVM System Property, Properties file.
      Parameters:
      name - The name of property.
      Returns:
      The value of property as String.
    • getProperty

      public <T> T getProperty(Property<T> property)
      Get the value of property by other property.
      Priority order: JVM System Property, Properties file, Default value.
      Type Parameters:
      T - The type of current property.
      Parameters:
      property - The Property to refer.
      Returns:
      The value of Property.
    • getProperties

      public Properties getProperties()
      Get all properties in this file.
      Returns:
      All properties have been read.