使用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
完成!