1. 源码
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;
}
}
2. 测试
@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());
}
最后
以上就是清秀狗最近收集整理的关于sun.security.action 源码学习07 GetPropertyAction的全部内容,更多相关sun.security.action内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复