Java Properties Get getString(Properties props, String name, String defaultValue)

Here you can find the source of getString(Properties props, String name, String defaultValue)

Description

Get a string property, or, if no such property is defined, return the given default value

License

Open Source License

Parameter

Parameter Description
props a parameter
name a parameter
defaultValue a parameter

Declaration

public static String getString(Properties props, String name, String defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    /**// w  w  w .j a v a 2  s .c om
     * Get a string property, or, if no such property is defined, return
     * the given default value
     *
     * @param props
     * @param name
     * @param defaultValue
     * @return
     */
    public static String getString(Properties props, String name, String defaultValue) {
        return props.containsKey(name) ? props.getProperty(name) : defaultValue;
    }

    public static String getString(Properties props, String name) {
        if (props.containsKey(name)) {
            return props.getProperty(name);
        }
        throw new IllegalArgumentException("Missing required property '" + name + "'");
    }
}

Related

  1. getSection(Properties props, String sectionName, boolean removeSectionName)
  2. getSignatureContent(Properties properties)
  3. getSignExclusions(Properties properties)
  4. getString(Properties props, String key)
  5. getString(Properties props, String name)
  6. getStringConfigValue( final String configKey, final Properties config)
  7. getStringConfigVaule(Properties properties, String key, String defaultValue)
  8. getSubProperties(Properties src, String prefix)
  9. getValue(Properties properties, String key)