Package com.saperion.ngc.configuration
Class PropertyFileLoader
java.lang.Object
com.saperion.ngc.configuration.PropertyFileLoader
Utility class to handle property-files.
-
Method Summary
Modifier and TypeMethodDescriptionloadFromClasspathAsMap
(String path, boolean caseSensitive) Loads the properties in the specified file.loadFromClasspathAsMapIgnoringError
(String path, boolean caseSensitive) Loads the properties in the specified file.
-
Method Details
-
loadFromClasspathAsMap
public static Map<String,String> loadFromClasspathAsMap(String path, boolean caseSensitive) throws IOException Loads the properties in the specified file. The file is expected to be in standard-properties format. The file is loaded by usingClass.getResourceAsStream(String)
. The keys of the returned map are not case sensitive.- Parameters:
path
- the path of the file (including name)caseSensitive
- whether to create a map with case-sensitive keys or not- Returns:
- properies loaded from the file in a map. Never null.
- Throws:
IOException
- when loading the file failed
-
loadFromClasspathAsMapIgnoringError
public static Map<String,String> loadFromClasspathAsMapIgnoringError(String path, boolean caseSensitive) Loads the properties in the specified file. The file is expected to be in standard-properties format. The file is loaded by usingClass.getResourceAsStream(String)
. The keys of the returned map are not case sensitive. If the file could not be read, an empty map is returned.- Parameters:
path
- the path of the file (including name)caseSensitive
- whether to create a map with case-sensitive keys or not- Returns:
- properies loaded from the file in a map. Never null.
-