public class PropertiesUtil
extends java.lang.Object
Constructor and Description |
---|
PropertiesUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.Properties |
createFromClasspath(java.lang.String... rootTemplate)
Creates properties from classpath.
|
static java.util.Properties |
createFromFile(java.io.File file)
Create properties from the file.
|
static java.util.Properties |
createFromFile(java.lang.String fileName)
Create properties from the file.
|
static java.util.Properties |
createFromString(java.lang.String data)
Creates properties from string.
|
static java.lang.String |
getProperty(java.util.Map map,
java.lang.String key)
Returns String property from a map.
|
static java.lang.String |
getProperty(java.util.Map map,
java.lang.String key,
java.lang.String defaultValue)
Returns String property from a map.
|
static java.util.Properties |
loadFromClasspath(java.util.Properties p,
java.lang.String... rootTemplate)
Loads properties from classpath file(s).
|
static void |
loadFromFile(java.util.Properties p,
java.io.File file)
Loads properties from the file.
|
static void |
loadFromFile(java.util.Properties p,
java.lang.String fileName)
Loads properties from the file.
|
static void |
loadFromString(java.util.Properties p,
java.lang.String data)
Loads properties from string.
|
static void |
resolveAllVariables(java.util.Properties prop)
Resolves all variables.
|
static java.lang.String |
resolveProperty(java.util.Map map,
java.lang.String key)
Returns property with resolved variables.
|
static java.util.Properties |
subset(java.util.Properties p,
java.lang.String prefix,
boolean stripPrefix)
Creates new Properties object from the original one, by copying
those properties that have specified first part of the key name.
|
static void |
writeToFile(java.util.Properties p,
java.io.File file)
Writes properties to a file.
|
static void |
writeToFile(java.util.Properties p,
java.io.File file,
java.lang.String header)
Writes properties to a file.
|
static void |
writeToFile(java.util.Properties p,
java.lang.String fileName)
Writes properties to a file.
|
static void |
writeToFile(java.util.Properties p,
java.lang.String fileName,
java.lang.String header)
Writes properties to a file.
|
public static java.util.Properties createFromFile(java.lang.String fileName) throws java.io.IOException
fileName
- properties file name to loadjava.io.IOException
public static java.util.Properties createFromFile(java.io.File file) throws java.io.IOException
file
- properties file to loadjava.io.IOException
public static void loadFromFile(java.util.Properties p, java.lang.String fileName) throws java.io.IOException
p
- properties to fill infileName
- properties file name to loadjava.io.IOException
public static void loadFromFile(java.util.Properties p, java.io.File file) throws java.io.IOException
p
- properties to fill infile
- file to read properties fromjava.io.IOException
public static void writeToFile(java.util.Properties p, java.lang.String fileName) throws java.io.IOException
p
- properties to write to filefileName
- destination file namejava.io.IOException
public static void writeToFile(java.util.Properties p, java.lang.String fileName, java.lang.String header) throws java.io.IOException
p
- properties to write to filefileName
- destination file nameheader
- optional headerjava.io.IOException
public static void writeToFile(java.util.Properties p, java.io.File file) throws java.io.IOException
p
- properties to write to filefile
- destination filejava.io.IOException
public static void writeToFile(java.util.Properties p, java.io.File file, java.lang.String header) throws java.io.IOException
p
- properties to write to filefile
- destination fileheader
- optional headerjava.io.IOException
public static java.util.Properties createFromString(java.lang.String data) throws java.io.IOException
java.io.IOException
public static void loadFromString(java.util.Properties p, java.lang.String data) throws java.io.IOException
java.io.IOException
public static java.util.Properties subset(java.util.Properties p, java.lang.String prefix, boolean stripPrefix)
p
- source properties, from which new object will be createdprefix
- key names prefixpublic static java.util.Properties createFromClasspath(java.lang.String... rootTemplate)
public static java.util.Properties loadFromClasspath(java.util.Properties p, java.lang.String... rootTemplate)
public static java.lang.String getProperty(java.util.Map map, java.lang.String key)
null
.
Mimics Property.getProperty
but on map.public static java.lang.String getProperty(java.util.Map map, java.lang.String key, java.lang.String defaultValue)
getProperty(java.util.Map, String)
public static void resolveAllVariables(java.util.Properties prop)
public static java.lang.String resolveProperty(java.util.Map map, java.lang.String key)
Copyright © 2003-present Jodd Team