ResourceBundle 的一种使用方法

使用ResourceBundle 来获取配置文件过程:

public void test() throws IOException{

        String proFilePath = "src/res.properties";
        BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(proFilePath));
        ResourceBundle rb = new PropertyResourceBundle(inputStream);
        String ssString = rb.getString("cancelKey");
        System.out.println(ssString);
    }

其中配置文件res.properpites中内容为:
cancelKey=cancel

执行代码:
得到输出:cancel
完成!

猜你喜欢

转载自blog.csdn.net/sinat_36220051/article/details/78787996