Java Properties Get getStringConfigVaule(Properties properties, String key, String defaultValue)

Here you can find the source of getStringConfigVaule(Properties properties, String key, String defaultValue)

Description

get String Config Vaule

License

Apache License

Declaration

public static String getStringConfigVaule(Properties properties, String key, String defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static String getStringConfigVaule(Properties properties, String key, String defaultValue) {
        return checkConfigValue(properties, key, defaultValue) ? properties.getProperty(key) : null;
    }/*w w  w. jav  a 2s. c  o m*/

    public static String getStringConfigVaule(Properties properties, String key) {
        return getStringConfigVaule(properties, key, null);
    }

    public static boolean checkConfigValue(Properties properties, String key) {
        return checkConfigValue(properties, key, null);
    }

    public static boolean checkConfigValue(Properties properties, String key, String defaultValue) {
        return checkConfigValue(properties, key, defaultValue, null);
    }

    public static boolean checkConfigValue(Properties properties, String key, String defaultValue,
            String errorMessage) {
        String value = System.getProperty(key);
        if (value == null || value.equals("")) {
            value = properties.getProperty(key, defaultValue);
            if (value == null || value.equals("")) {
                return false;
            } else {
                properties.setProperty(key, value);
                return true;
            }
        } else {
            properties.setProperty(key, value);
            return true;
        }
    }
}

Related

  1. getSignExclusions(Properties properties)
  2. getString(Properties props, String key)
  3. getString(Properties props, String name)
  4. getString(Properties props, String name, String defaultValue)
  5. getStringConfigValue( final String configKey, final Properties config)
  6. getSubProperties(Properties src, String prefix)
  7. getValue(Properties properties, String key)