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

voidclearPrefixedSystemProperties(String prefix, Map targetPropertyMap)
clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefix
for (Object o : System.getProperties().keySet()) {
    String propertyName = (String) o;
    if (propertyName.startsWith(prefix) && !targetPropertyMap.containsKey(propertyName)) {
        targetPropertyMap.put(propertyName, null);
voidcopyProperties(Hashtable src, Hashtable target)
This API copies the properties from src hashtable to the target hashtable
Enumeration keys = src.keys();
while (keys.hasMoreElements()) {
    Object key = keys.nextElement();
    Object value = src.get(key);
    target.put(key, value);
booleangetBoolean(Properties props, String key)
get Boolean
return getBoolean(props, key, false);
booleangetBoolean(Properties props, String name, boolean defaultValue)
get Boolean
if (!props.containsKey(name))
    return defaultValue;
return "true".equalsIgnoreCase(props.getProperty(name));
intgetInt(Properties props, String name)
get Int
if (props.containsKey(name)) {
    return getInt(props, name, -1);
throw new IllegalArgumentException("Missing required property '" + name + "'");
intgetInt(Properties props, String name, int defaultValue)
get Int
return getIntInRange(props, name, defaultValue, Integer.MIN_VALUE, Integer.MAX_VALUE);
MapgetIntersectionOfPropertyValues(Properties propertyFileOne, Properties propertyFileTwo)
get Intersection Of Property Values
Map<String, String> intersection = new HashMap<String, String>();
for (String key : propertyFileOne.stringPropertyNames()) {
    String propertyOneValue = propertyFileOne.getProperty(key);
    String propertyTwoValue = propertyFileTwo.getProperty(key);
    if (propertyOneValue != null && propertyTwoValue != null && propertyOneValue.equals(propertyTwoValue)) {
        intersection.put(key, propertyOneValue);
return intersection;
intgetIntInRange(Properties props, String name, int defaultValue, int min, int max)
get Int In Range
int v = defaultValue;
if (props.containsKey(name)) {
    v = Integer.valueOf(props.getProperty(name));
if (v >= min && v <= max) {
    return v;
throw new IllegalArgumentException(name + " has value " + v + " which is not in the range");
...
intgetIntProperty(Properties props, String keyword, int defaultValue)
get Int Property
int rv = defaultValue;
if (props != null) {
    String s = props.getProperty(keyword);
    if (s != null) {
        s = s.trim();
        if (!s.isEmpty()) {
            try {
                rv = Integer.parseInt(s);
...
booleangetIsB37PropertyValue(final Properties dataSourceProperties)
Get if the properties has specified the `isB37` field #CONFIG_FILE_FIELD_NAME_IS_B37_DATA_SOURCE as true.
if (dataSourceProperties.containsKey(CONFIG_FILE_FIELD_NAME_IS_B37_DATA_SOURCE)) {
    return Boolean.valueOf(
            dataSourceProperties.getProperty(CONFIG_FILE_FIELD_NAME_IS_B37_DATA_SOURCE).replace(" ", ""));
return false;