public final class PropertiesUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getProperty(Properties props,
String key,
String def)
Return the value of a property.
|
static String[] |
readListFile(URL listFile)
Read a file and return the list of lines in an array of strings.
|
static Properties |
readProperties(InputStream stream,
Properties mappings,
boolean closeStream)
Read a set of properties from a property file provided as an Inputstream.
|
static Properties |
readProps(URL propsUrl,
Properties mappings)
Read a set of properties from a property file specificed by a url.
|
static String |
resolveProperty(Properties props,
String value)
Resolve symbols in a supplied value against supplied known properties.
|
public static Properties readProps(URL propsUrl, Properties mappings) throws IOException
propsUrl
- the url of the property file to readmappings
- Properties that will be available for translations initially.IOException
- if an io error occursreadProperties(java.io.InputStream,java.util.Properties,boolean)
public static Properties readProperties(InputStream stream, Properties mappings, boolean closeStream) throws IOException
mappings
properties as well as all values within the Properties that are being read.
Example;
Properties mappings = System.getProperties();
Properties myProps = PropertiesUtils.readProperties( "mine.properties", mappings );
and the "mine.properties" file contains;
mything=${myplace}/mything
myplace=${user.home}/myplace
then the Properties object myProps will contain;
mything=/home/niclas/myplace/mything
myplace=/home/niclas/myplace
stream
- the InputStream of the property file to read.mappings
- Properties that will be available for translations initially.closeStream
- true if the method should close the stream before returning, false otherwise.IOException
- if an io error occurspublic static String resolveProperty(Properties props, String value)
props
- a set of know propertiesvalue
- the string to parse for tokenspublic static String getProperty(Properties props, String key, String def)
props
- the property filekey
- the property key to lookupdef
- the default valuepublic static String[] readListFile(URL listFile) throws IOException
listFile
- the url to read fromIOException
- if a read error occursCopyright © 2006–2019 OPS4J - Open Participation Software for Java. All rights reserved.