我想将新属性添加到文件中已存在的属性中。我做到了,但是在此过程中已经更改了现有属性。 这是我使用的代码:
FileInputStream configStream = new FileInputStream(propsFileName);
props.load(configStream);
configStream.close();
props.setProperty("connection", "new connection settings go here");
FileOutputStream output = new FileOutputStream(propsFileName);
props.store(output, "This description goes to the header of a file");
output.close();
这是最初的样子:
projectKey=trialProject
host=http:\\localhost:9000
projectPath=C:\\Users\\Elif\\Desktop\\trialProject
这就是它的样子:
#This description goes to the header of a file
#Fri Jul 19 00:42:08 EET 2019
projectKey=trialProject
connection=new connection settings go here
host=http\:\\localhost\:9000
projectPath=C\:\\Users\\Elif\\Desktop\\trialProject
反斜杠更改。