我是靠谱客的博主 清秀狗,这篇文章主要介绍sun.security.action 源码学习07 GetPropertyAction,现在分享给大家,希望可以做个参考。

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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(113)

评论列表共有 0 条评论

立即
投稿
返回
顶部