Basic Environments

To define the current used environment you can use the constructor new PrefixedProperties("prefix") or set the default environment with prefixedProperties.setDefaultPrefix("prefix") which has the same effect as using the constructor.

Example:

In this example a property named URL exists in three versions for three different environments.
With PrefixedProperties you can easily configure all three properties at once without the need to work with different files.

properties-file:

  test.URL=http://some.fance.url
  liv.URL=htpps://some.secure.url
  dev.URL=file:/usingALocalFile.url

usage with PrefixedProperties:

  //for development environment
  PrefixedProperties properties = new PrefixedProperties("dev");
  properties.load("A_Properties_File.properties");
  properties.get("URL"); //will return "file:/usingALocalFile.url"
  
  //switch the environment to test
  properties.setDefaultPrefix("test");
  properties.get("URL"); //will return "http://some.fance.url"