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 |
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 String |
getResourceAsString(String resourcesFile)
Get the String content from the Resources directory
|
static File |
getResourceFile(String resourcesFile)
Get the File representation from the local path to the Resources directory
|
static Stream<String> |
getResourceListing(Class clazz,
String path) |
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 InputStream getConfigAsStream(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static InputStream getResourceAsStream(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static File getResourceFile(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundpublic static Path getResourcePath(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if resource file not foundpublic static Stream<String> getResourceListing(Class clazz, String path) throws URISyntaxException, IOException
URISyntaxException
IOException
public static File findFile(String filename) throws FileNotFoundException
filename
- the file nameFileNotFoundException
- if not fountpublic static File fileFromConfigFolder(String subpath)
subpath
- the subpath under Config folderpublic static File fileFromDataFolder(String subpath)
subpath
- the subpath under Data folderpublic static File fileFromTmpFolder(String subpath)
subpath
- the subpath under Tmp folderpublic static Properties readProperties(File propertiesFile) throws IOException
propertiesFile
- properties fileIOException
- if cannot load filepublic static <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 <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 <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 <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 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 occurredpublic static String getResourceAsString(String resourcesFile) throws FileNotFoundException
resourcesFile
- properties file from resources directoryFileNotFoundException
- if the resource file not foundCopyright © 2019 Vitam. All rights reserved.