Class ConfigurationUtil
- java.lang.Object
-
- org.eclipse.rdf4j.common.app.util.ConfigurationUtil
-
public class ConfigurationUtil extends java.lang.Object
Configuration helper class
-
-
Constructor Summary
Constructors Constructor Description ConfigurationUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getDefaultResourceName(java.lang.String resourceName)
Get full resource name from default locationprivate static java.lang.String
getResourceName(java.lang.String resourceName)
Get full resource namestatic java.lang.String
loadConfigurationContents(java.io.File file)
Load configuration settings from the specified file.static java.lang.String
loadConfigurationContents(java.lang.String resourceName)
Load configuration settings from a resource on the classpath.static java.util.Properties
loadConfigurationProperties(java.io.File file, java.util.Properties defaults)
Load configuration properties from the specified file.static java.util.Properties
loadConfigurationProperties(java.lang.String resourceName, java.util.Properties defaults)
Load configuration properties from a resource on the classpath.static void
saveConfigurationContents(java.lang.String contents, java.io.File file)
Save configuration settings to a file.static void
saveConfigurationProperties(java.util.Properties props, java.io.File file, boolean includeDefaults)
Save configuration properties to a file.
-
-
-
Method Detail
-
loadConfigurationContents
public static java.lang.String loadConfigurationContents(java.io.File file) throws java.io.IOException
Load configuration settings from the specified file.- Parameters:
file
- the file to load from- Returns:
- the contents of the file as a String, or null if the file did not exist
- Throws:
java.io.IOException
- if the contents of the file could not be read due to an I/O problem
-
loadConfigurationContents
public static java.lang.String loadConfigurationContents(java.lang.String resourceName) throws java.io.IOException
Load configuration settings from a resource on the classpath.- Parameters:
resourceName
- the name of the resource- Returns:
- the contents of the resources as a String, or null if the resource, nor its default, could be found
- Throws:
java.io.IOException
- if the resource could not be read due to an I/O problem
-
loadConfigurationProperties
public static java.util.Properties loadConfigurationProperties(java.io.File file, java.util.Properties defaults) throws java.io.IOException
Load configuration properties from the specified file.- Parameters:
file
- the file to load fromdefaults
- default properties- Returns:
- the contents of the file as Properties, or null if the file did not exist
- Throws:
java.io.IOException
- if the contents of the file could not be read due to an I/O problem
-
loadConfigurationProperties
public static java.util.Properties loadConfigurationProperties(java.lang.String resourceName, java.util.Properties defaults) throws java.io.IOException
Load configuration properties from a resource on the classpath.- Parameters:
resourceName
- the name of the resourcedefaults
- default properties- Returns:
- the contents of the resource as Properties
- Throws:
java.io.IOException
- if the resource could not be read due to an I/O problem
-
getResourceName
private static java.lang.String getResourceName(java.lang.String resourceName)
Get full resource name- Parameters:
resourceName
- relative resource name- Returns:
- full resource location
-
getDefaultResourceName
private static java.lang.String getDefaultResourceName(java.lang.String resourceName)
Get full resource name from default location- Parameters:
resourceName
- relative resource name- Returns:
- full default resource location
-
saveConfigurationContents
public static void saveConfigurationContents(java.lang.String contents, java.io.File file) throws java.io.IOException
Save configuration settings to a file.- Parameters:
contents
- the configuration settingsfile
- the file to write to- Throws:
java.io.IOException
- if the settings could not be saved because of an I/O problem
-
saveConfigurationProperties
public static void saveConfigurationProperties(java.util.Properties props, java.io.File file, boolean includeDefaults) throws java.io.IOException
Save configuration properties to a file.- Parameters:
props
- the configuration propertiesfile
- the file to write toincludeDefaults
-- Throws:
java.io.IOException
- if the settings could not be saved because of an I/O problem
-
-