getProperty(String key) 获取指定键指示的系统属性(从系统环境或*.properties等配置文件中读取key对应的值)。this
getProperty(String key, String def) 获取用指定键描述的系统属性(从系统环境或*.properties等配置文件中读取key对应的值,当key值为NULL时,返回def的值; 当key值不为NULL时,返回key的值 )。spa
1.public static String getProperty(String key, String def) {get
SecurityManager sm = getSecurityManager();it
if (sm != null) {配置
sm.checkPropertyAccess(key);coding
return props.getProperty(key, def);配置文件
//当getProperty(key);为null时,返回defaultValue(即便传入的def值)static
public String getProperty(String key, String defaultValue) {di
String val = getProperty(key);文件
return (val == null) ? defaultValue : val;
private String encoding = "GBK";
public JavaModel(Map<String, ?> environment)
super(environment);
//mod.encoding为system.properties配置文件中设置的键值对
this.encoding = System.getProperty("mod.encoding", this.encoding);