Here you can find the source of getProperty(Properties props, String propname)
Parameter | Description |
---|---|
props | - property set in which to look. |
propname | - name of the property to lookup. |
public static String getProperty(Properties props, String propname)
//package com.java2s; import java.util.*; public class Main { /**/*from w ww. j a v a 2 s. c om*/ * 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. This is especially useful * for defining the marc.source property to define which file to operate on, in a shell script loop. * * @param props - property set in which to look. * @param propname - name of the property to lookup. * @returns String - value stored for that property (or null if it doesn't exist) */ public static String getProperty(Properties props, String propname) { return getProperty(props, propname, null); } /** * 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. This is especially useful * for defining the marc.source property to define which file to operate on, in a shell script loop. * * @param props - property set in which to look. * @param propname - name of the property to lookup. * @param defVal - the default value to use if property is not defined * @returns String - value stored for that property (or the if it doesn't exist) */ public static String getProperty(Properties props, String propname, String defVal) { String prop; if ((prop = System.getProperty(propname)) != null) { return (prop); } if (props != null && (prop = props.getProperty(propname)) != null) { return (prop); } return defVal; } }