public class GetPropertyAction implements PrivilegedAction<String> {
private String theProp;
private String defaultVal;
public GetPropertyAction(String var1) {
this.theProp = var1;
}
public GetPropertyAction(String var1, String var2) {
this.theProp = var1;
this.defaultVal = var2;
}
public String run() {
String var1 = System.getProperty(this.theProp);
return var1 == null?this.defaultVal:var1;
}
}
@Test
public void test03(){
GetPropertyAction propertyAction = new GetPropertyAction("file.separator");
System.out.println(propertyAction.run()); // result : \
}
@Test
public void test04(){
GetPropertyAction propertyAction = new GetPropertyAction("a","ccc");
System.out.println(propertyAction.run());
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章