Java Utililty Methods Properties Get

List of utility methods to do Properties Get

Description

The list of methods to do Properties Get are organized into topic(s).

Method

StringgetProperty(Properties props, String propname)
Check first for a particular property in the System Properties, so that the -Dprop="value" command line arg mechanism can be used to override values defined in the passed in property file.
return getProperty(props, propname, null);
StringgetProperty(String[] system_props, Properties props, String prop_name, boolean ignore_sysprops, String default_value)
Returns a value associated wither with one or more system properties, or found in the props map
String retval = null;
if (props != null && prop_name != null) {
    retval = props.getProperty(prop_name);
    props.remove(prop_name);
if (!ignore_sysprops) {
    String tmp, prop;
    if (system_props != null) {
...
doublegetPropertyDouble(Properties p, String key)
convert a properties value into an int
Object test = p.get(key);
if (test == null)
    return (Double.MIN_VALUE);
return (Double.parseDouble(test.toString()));
LonggetPropertyLong(Properties properties, String context, String key, Long def)
Delegates to #getProperty(Properties,String,String,String) but returns the value as an Long where Long#valueOf(String) defines the actual value
return Long.valueOf(getProperty(properties, context, key, def == null ? null : def.toString()));
StringgetPropertyString(Properties properties, String propertyName)
get Property String
String value = "";
value = properties.getProperty(propertyName);
if (value == null) {
    return "";
;
return value;
StringgetPropertyText(String property, Object... replacements)
get Property Text
String message;
if (APPLICATION_RESOURCES.containsKey(property)) {
    message = APPLICATION_RESOURCES.getString(property);
} else {
    message = RESOURCES.getString(property);
if (message.contains("'") && !message.contains("''")) {
    message = message.replaceAll("(.)'(.)", "$1''$2");
...
StringgetPropertyValue(Properties props, String key)
get Property Value
return getPropertyValue(props, key, EMPTY_STRING);
intgetPropertyValueAsInt(Properties props, String key, int defaultValue)
Get integer value from given properties.
return props == null || !props.containsKey(key) ? defaultValue : Integer.parseInt(props.getProperty(key));
StringgetRefValue(Properties result, String v)
get Ref Value
while (v != null && v.startsWith(REF)) {
    String ref = v.substring(1);
    v = result.getProperty(ref);
    if (v == null) {
        v = System.getProperty(ref);
return v == null ? "" : v;
...
PropertiesgetSection(Properties props, String sectionName, boolean removeSectionName)
get Section
Properties ret = new Properties();
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
    String key = (String) (e.nextElement());
    if (key.startsWith(sectionName + ".")) {
        String newkey = removeSectionName ? key.substring(sectionName.length() + 1) : key;
        ret.setProperty(newkey, props.getProperty(key));
    } else if (key.equals(sectionName) && !removeSectionName) {
        ret.setProperty(key, props.getProperty(key));
...