Package fr.gouv.vitam.common
Class PropertiesUtils
java.lang.Object
fr.gouv.vitam.common.PropertiesUtils
Property Utility class
NOTE for developers: Do not add LOGGER there
-
Method Summary
Modifier and TypeMethodDescriptionstatic FilefileFromConfigFolder(String subpath) Return a full file path using Config folder as root and subpath as sub paths.static FilefileFromDataFolder(String subpath) Return a full file path using Data folder as root and subpath as sub paths.static FilefileFromTmpFolder(String subpath) Return a full file path using Tmp folder as root and subpath as sub paths.static FileGet the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as Resources filestatic InputStreamgetConfigAsStream(String resourcesFile) Get the InputStream representation from the local path to the Resources directorystatic FilegetConfigFile(String resourcesFile) Get the InputStream representation from the local path to the Resources directorystatic InputStreamgetResourceAsStream(String resourcesFile) Get the InputStream representation from the Resources directorystatic StringgetResourceAsString(String resourcesFile) Get the String content from the Resources directorystatic FilegetResourceFile(String resourcesFile) Get the File representation from the local path to the Resources directorygetResourceListing(Class clazz, String path) static PathgetResourcePath(String resourcesFile) Get the Path representation from the local path to the Resources directorystatic PropertiesreadProperties(File propertiesFile) Read a properties file and returns the associated Propertiesstatic <C> CRead the Yaml file and return the object readstatic <C> CRead the Yaml file and return the object readstatic <C> CreadYaml(InputStream yamlInputStream, Class<C> clasz) Read the Yaml InputStream and return the object readstatic <C> CRead the Yaml file and return the object readstatic voidWrite the Yaml file
-
Method Details
-
getConfigAsStream
Get the InputStream representation from the local path to the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException- if the resource file not found
-
getConfigFile
Get the InputStream representation from the local path to the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException- if the resource file not found
-
getResourceAsStream
Get the InputStream representation from the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException- if the resource file not found
-
getResourceFile
Get the File representation from the local path to the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated File
- Throws:
FileNotFoundException- if the resource file not found
-
getResourcePath
Get the Path representation from the local path to the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated Path
- Throws:
FileNotFoundException- if resource file not found
-
getResourceListing
public static Stream<String> getResourceListing(Class clazz, String path) throws URISyntaxException, IOException - Throws:
URISyntaxExceptionIOException
-
findFile
Get the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as Resources file- Parameters:
filename- the file name- Returns:
- the File if found
- Throws:
FileNotFoundException- if not fount
-
fileFromConfigFolder
Return a full file path using Config folder as root and subpath as sub paths.- Parameters:
subpath- the subpath under Config folder- Returns:
- the full file path (no check on existing is done)
-
fileFromDataFolder
Return a full file path using Data folder as root and subpath as sub paths.- Parameters:
subpath- the subpath under Data folder- Returns:
- the full file path (no check on existing is done)
-
fileFromTmpFolder
Return a full file path using Tmp folder as root and subpath as sub paths.- Parameters:
subpath- the subpath under Tmp folder- Returns:
- the full file path (no check on existing is done)
-
readProperties
Read a properties file and returns the associated Properties- Parameters:
propertiesFile- properties file- Returns:
- the associated Properties
- Throws:
IOException- if cannot load file
-
readYaml
Read the Yaml file and return the object read- Parameters:
yamlFile- the yaml file to readclasz- the class representing the target object- Returns:
- the object read
- Throws:
IOException- if read yaml input stream to class template exception occurred
-
readYaml
public static <C> C readYaml(File yamlFile, com.fasterxml.jackson.core.type.TypeReference<C> typeReference) throws IOException Read the Yaml file and return the object read- Parameters:
yamlFile- the yaml filetypeReference- the type reference representing the target interface object- Returns:
- the object read
- Throws:
IOException- if read yaml input stream to class template exception occurred
-
readYaml
Read the Yaml InputStream and return the object read- Parameters:
yamlInputStream- the yaml input stream to readclasz- the class representing the target object- Returns:
- the object read
- Throws:
IOException- if read yaml input stream to class template exception occurred
-
readYaml
Read the Yaml file and return the object read- Parameters:
yamlPath- yaml file pathclasz- the class representing the target object- Returns:
- the object read
- Throws:
IOException- if file not found exception
-
writeYaml
Write the Yaml file- Parameters:
destination- the destination fileconfig- the configuration object to write using Yaml format- Throws:
IOException- if write object config exception occurred
-
getResourceAsString
Get the String content from the Resources directory- Parameters:
resourcesFile- properties file from resources directory- Returns:
- the associated File content as a String
- Throws:
FileNotFoundException- if the resource file not found
-