我想在屬性文件中保留一些屬性,以防程序運行期間發生更改。現在我試圖這樣做: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