我想在属性文件中保留一些属性,以防程序运行期间发生更改。现在我试图这样做:Java:在类路径上加载和编辑属性文件
Properties properties = new Properties();
try (FileInputStream in = new FileInputStream("classpath:app.properties")) {
properties.load(in);
} catch (IOException e) {
logger.error("", e);
}
properties.setProperty("word", "abc");
try (FileOutputStream out = new FileOutputStream("classpath:app.properties")) {
properties.store(out, null);
} catch (IOException e) {
logger.error("", e);
}
但它似乎并没有工作。我究竟做错了什么?
嗯,我试图做同样的事情,并注意到我的属性并未实际加载。我无法获得我在文件中定义的道具。 – pbespechnyi 2014-10-30 20:02:39