Java Properties Get getProperty(Properties props, String propertyName)

Here you can find the source of getProperty(Properties props, String propertyName)

Description

Reads system variable (cmd option) or config file value on fail

License

Open Source License

Parameter

Parameter Description
props config file
propertyName config/cmd property name

Return

value

Declaration

public static String getProperty(Properties props, String propertyName) 

Method Source Code

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

import java.util.*;

public class Main {
    /**//from   w  w  w  . j  a v a2s .co  m
     * Reads system variable (cmd option) or config file value on fail
     *
     * @param props        config file
     * @param propertyName config/cmd property name
     * @return value
     */
    public static String getProperty(Properties props, String propertyName) {
        return System.getProperty(propertyName, props.getProperty(propertyName));
    }

    /**
     * Reads system variable (cmd option) or config file value on fail
     *
     * @param props        config file to get value from if not specified via cmd
     * @param propertyName config/cmd property name to get value from
     * @param defaultValue value to use if not specified via cmd and config
     * @return value
     */
    public static String getProperty(Properties props, String propertyName, String defaultValue) {
        return System.getProperty(propertyName, props.getProperty(propertyName, defaultValue));
    }
}

Related

  1. getPropertiesForBloomFilter( int requiredFieldsSize, int matchKeySize)
  2. getPropertiesWithPrefix(Properties pro, String prefix)
  3. getProperty(Properties properties, String context, String key, String def)
  4. getProperty(Properties props, String keyword)
  5. getProperty(Properties props, String prefix, String key)
  6. getProperty(Properties props, String propname)
  7. getProperty(String[] system_props, Properties props, String prop_name, boolean ignore_sysprops, String default_value)
  8. getPropertyDouble(Properties p, String key)
  9. getPropertyLong(Properties properties, String context, String key, Long def)