properties文件 store后,原来值被修改
sgxu 2018-09-12 10:31:44 这是没有store时文件中的值
jdbc.url=jdbc:mysql://localhost:3306/?useUnicode=true&characterEncoding=utf8
这是store后文件中的值,多加了斜杠
jdbc.url=jdbc\:mysql\://localhost\:3306/xxx?useUnicode\=true&characterEncoding\=utf8
代码如下:
Properties prop = new Properties();
try {
InputStream fis = new FileInputStream(filePath);
prop.load(fis);
prop.setProperty("aaa", "xxx");
prop.store(new OutputStreamWriter(
new FileOutputStream(filePath), "UTF-8"),
new Date().toString());
} catch (IOException e) {
e.printStackTrace();
}