Package fr.gouv.vitam.common
Class PropertiesUtils
- java.lang.Object
- 
- fr.gouv.vitam.common.PropertiesUtils
 
- 
 public final class PropertiesUtils extends java.lang.ObjectProperty Utility class NOTE for developers: Do not add LOGGER there
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.FilefileFromConfigFolder(java.lang.String subpath)Return a full file path using Config folder as root and subpath as sub paths.static java.io.FilefileFromDataFolder(java.lang.String subpath)Return a full file path using Data folder as root and subpath as sub paths.static java.io.FilefileFromTmpFolder(java.lang.String subpath)Return a full file path using Tmp folder as root and subpath as sub paths.static java.io.FilefindFile(java.lang.String filename)Get the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as Resources filestatic java.io.InputStreamgetConfigAsStream(java.lang.String resourcesFile)Get the InputStream representation from the local path to the Resources directorystatic java.io.InputStreamgetResourceAsStream(java.lang.String resourcesFile)Get the InputStream representation from the Resources directorystatic java.lang.StringgetResourceAsString(java.lang.String resourcesFile)Get the String content from the Resources directorystatic java.io.FilegetResourceFile(java.lang.String resourcesFile)Get the File representation from the local path to the Resources directorystatic java.util.stream.Stream<java.lang.String>getResourceListing(java.lang.Class clazz, java.lang.String path)static java.nio.file.PathgetResourcePath(java.lang.String resourcesFile)Get the Path representation from the local path to the Resources directorystatic java.util.PropertiesreadProperties(java.io.File propertiesFile)Read a properties file and returns the associated Propertiesstatic <C> CreadYaml(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<C> typeReference)Read the Yaml file and return the object readstatic <C> CreadYaml(java.io.File yamlFile, java.lang.Class<C> clasz)Read the Yaml file and return the object readstatic <C> CreadYaml(java.io.InputStream yamlInputStream, java.lang.Class<C> clasz)Read the Yaml InputStream and return the object readstatic <C> CreadYaml(java.nio.file.Path yamlPath, java.lang.Class<C> clasz)Read the Yaml file and return the object readstatic voidwriteYaml(java.io.File destination, java.lang.Object config)Write the Yaml file
 
- 
- 
- 
Method Detail- 
getConfigAsStreampublic static java.io.InputStream getConfigAsStream(java.lang.String resourcesFile) throws java.io.FileNotFoundExceptionGet the InputStream representation from the local path to the Resources directory- Parameters:
- resourcesFile- properties file from resources directory
- Returns:
- the associated File
- Throws:
- java.io.FileNotFoundException- if the resource file not found
 
 - 
getResourceAsStreampublic static java.io.InputStream getResourceAsStream(java.lang.String resourcesFile) throws java.io.FileNotFoundExceptionGet the InputStream representation from the Resources directory- Parameters:
- resourcesFile- properties file from resources directory
- Returns:
- the associated File
- Throws:
- java.io.FileNotFoundException- if the resource file not found
 
 - 
getResourceFilepublic static java.io.File getResourceFile(java.lang.String resourcesFile) throws java.io.FileNotFoundExceptionGet the File representation from the local path to the Resources directory- Parameters:
- resourcesFile- properties file from resources directory
- Returns:
- the associated File
- Throws:
- java.io.FileNotFoundException- if the resource file not found
 
 - 
getResourcePathpublic static java.nio.file.Path getResourcePath(java.lang.String resourcesFile) throws java.io.FileNotFoundExceptionGet the Path representation from the local path to the Resources directory- Parameters:
- resourcesFile- properties file from resources directory
- Returns:
- the associated Path
- Throws:
- java.io.FileNotFoundException- if resource file not found
 
 - 
getResourceListingpublic static java.util.stream.Stream<java.lang.String> getResourceListing(java.lang.Class clazz, java.lang.String path) throws java.net.URISyntaxException, java.io.IOException- Throws:
- java.net.URISyntaxException
- java.io.IOException
 
 - 
findFilepublic static java.io.File findFile(java.lang.String filename) throws java.io.FileNotFoundExceptionGet 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:
- java.io.FileNotFoundException- if not fount
 
 - 
fileFromConfigFolderpublic static java.io.File fileFromConfigFolder(java.lang.String subpath) 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)
 
 - 
fileFromDataFolderpublic static java.io.File fileFromDataFolder(java.lang.String subpath) 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)
 
 - 
fileFromTmpFolderpublic static java.io.File fileFromTmpFolder(java.lang.String subpath) 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)
 
 - 
readPropertiespublic static java.util.Properties readProperties(java.io.File propertiesFile) throws java.io.IOExceptionRead a properties file and returns the associated Properties- Parameters:
- propertiesFile- properties file
- Returns:
- the associated Properties
- Throws:
- java.io.IOException- if cannot load file
 
 - 
readYamlpublic static <C> C readYaml(java.io.File yamlFile, java.lang.Class<C> clasz) throws java.io.IOExceptionRead the Yaml file and return the object read- Parameters:
- yamlFile- the yaml file to read
- clasz- the class representing the target object
- Returns:
- the object read
- Throws:
- java.io.IOException- if read yaml input stream to class template exception occurred
 
 - 
readYamlpublic static <C> C readYaml(java.io.File yamlFile, com.fasterxml.jackson.core.type.TypeReference<C> typeReference) throws java.io.IOExceptionRead the Yaml file and return the object read- Parameters:
- yamlFile- the yaml file
- typeReference- the type reference representing the target interface object
- Returns:
- the object read
- Throws:
- java.io.IOException- if read yaml input stream to class template exception occurred
 
 - 
readYamlpublic static <C> C readYaml(java.io.InputStream yamlInputStream, java.lang.Class<C> clasz) throws java.io.IOExceptionRead the Yaml InputStream and return the object read- Parameters:
- yamlInputStream- the yaml input stream to read
- clasz- the class representing the target object
- Returns:
- the object read
- Throws:
- java.io.IOException- if read yaml input stream to class template exception occurred
 
 - 
readYamlpublic static <C> C readYaml(java.nio.file.Path yamlPath, java.lang.Class<C> clasz) throws java.io.IOExceptionRead the Yaml file and return the object read- Parameters:
- yamlPath- yaml file path
- clasz- the class representing the target object
- Returns:
- the object read
- Throws:
- java.io.IOException- if file not found exception
 
 - 
writeYamlpublic static void writeYaml(java.io.File destination, java.lang.Object config) throws java.io.IOExceptionWrite the Yaml file- Parameters:
- destination- the destination file
- config- the configuration object to write using Yaml format
- Throws:
- java.io.IOException- if write object config exception occurred
 
 - 
getResourceAsStringpublic static java.lang.String getResourceAsString(java.lang.String resourcesFile) throws java.io.FileNotFoundExceptionGet the String content from the Resources directory- Parameters:
- resourcesFile- properties file from resources directory
- Returns:
- the associated File content as a String
- Throws:
- java.io.FileNotFoundException- if the resource file not found
 
 
- 
 
-