获取配置文件中key=value

之前一直是写一个方法获取配置文件中的key=value值得,现在提供更简单的。

ResourceBundle 是java.utl中的一个专门针对.properties文件的。
//获取配置文件对象
    ResourceBundle bundle = ResourceBundle.getBundle("sendsms");
    //获取配置文件内容
    //获取key
    final String accessKeyId = bundle.getString("accessKeyId");
    //获取密钥
    final String accessKeySecret = bundle.getString("accessKeySecret");

 

posted @ 2019-01-07 15:45  kerala  阅读(223)  评论(0编辑  收藏  举报