public final class PropertiesUtils extends Object
Modifier and Type | Method and Description |
---|---|
static File |
fileFromConfigFolder(String subpath)
Return a full file path using Config folder as root and subpath as sub paths.
|
static File |
fileFromDataFolder(String subpath)
Return a full file path using Data folder as root and subpath as sub paths.
|
static File |
fileFromLogFolder(String subpath)
Return a full file path using Log folder as root and subpath as sub paths.
|
static File |
fileFromTmpFolder(String subpath)
Return a full file path using Tmp folder as root and subpath as sub paths.
|
static File |
findFile(String filename)
Get the File associated with this filename, trying in this order: as fullpath, as in Vitam Config Folder, as
Resources file
|
static InputStream |
getConfigAsStream(String resourcesFile)
Get the InputStream representation from the local path to the Resources directory
|
static InputStream |
getResourceAsStream(String resourcesFile)
Get the InputStream representation from the Resources directory
|
static File |
getResourceFile(String resourcesFile)
Get the File representation from the local path to the Resources directory
|
static Path |
getResourcePath(String resourcesFile)
Get the Path representation from the local path to the Resources directory
|
static Properties |
readProperties(File propertiesFile)
Read a properties file and returns the associated Properties
|
static <C> C |
readYaml(File yamlFile,
Class<C> clasz)
Read the Yaml file and return the object read
|
static <C> C |
readYaml(File yamlFile,
com.fasterxml.jackson.core.type.TypeReference<C> typeReference)
Read the Yaml file and return the object read
|
static <C> C |
readYaml(InputStream yamlInputStream,
Class<C> clasz)
Read the Yaml InputStream and return the object read
|
static <C> C |
readYaml(Path yamlPath,
Class<C> clasz)
Read the Yaml file and return the object read
|
static void |
writeYaml(File destination,
Object config)
Write the Yaml file
|
public static final InputStream getConfigAsStream(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static final InputStream getResourceAsStream(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static final File getResourceFile(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static final Path getResourcePath(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if resource file not foundpublic static final File findFile(String filename) throws FileNotFoundException
filename
- the file nameFileNotFoundException
- if not fountpublic static final File fileFromConfigFolder(String subpath)
subpath
- the subpath under Config folderpublic static final File fileFromDataFolder(String subpath)
subpath
- the subpath under Data folderpublic static final File fileFromLogFolder(String subpath)
subpath
- the subpath under Log folderpublic static final File fileFromTmpFolder(String subpath)
subpath
- the subpath under Tmp folderpublic static final Properties readProperties(File propertiesFile) throws IOException
propertiesFile
- properties fileIOException
- if cannot load filepublic static final <C> C readYaml(File yamlFile, Class<C> clasz) throws IOException
yamlFile
- the yaml file to readclasz
- the class representing the target objectIOException
- if read yaml input stream to class template exception occurredpublic static final <C> C readYaml(File yamlFile, com.fasterxml.jackson.core.type.TypeReference<C> typeReference) throws IOException
yamlFile
- the yaml filetypeReference
- the type reference representing the target interface objectIOException
- if read yaml input stream to class template exception occurredpublic static final <C> C readYaml(InputStream yamlInputStream, Class<C> clasz) throws IOException
yamlInputStream
- the yaml input stream to readclasz
- the class representing the target objectIOException
- if read yaml input stream to class template exception occurredpublic static final <C> C readYaml(Path yamlPath, Class<C> clasz) throws IOException
yamlPath
- yaml file pathclasz
- the class representing the target objectIOException
- if file not found exceptionpublic static final void writeYaml(File destination, Object config) throws IOException
destination
- the destination fileconfig
- the configuration object to write using Yaml formatIOException
- if write object config exception occurredCopyright © 2018 Vitam. All rights reserved.