我正在使用下面的代碼在.properties文件中編寫屬性。如何在一個.properties文件末尾添加屬性
InputStream inputStream = null;
try {
inputStream = file.getContents();
Properties properties = new Properties();
properties.load(inputStream);
inputStream.close();
properties.setProperty(propertyKey.trim(), propertyValue.trim());
File file1 = file.getRawLocation().makeAbsolute().toFile();
FileOutputStream outputStream = new FileOutputStream(file1);
properties.store(outputStream, null);
outputStream.close();
}
} catch (IOException ex) {
ex.printStackTrace();
} catch (CoreException ex) {
ex.printStackTrace();
}
雖然它是在一個排序位次但不是。但我想它會永遠被添加at the end
我。怎麼可以得到的末尾添加屬性?
由於您似乎正在使用'IFile',因此您應該使用'IFile.setContents'來保存文件。您當前的方法將使該文件與Eclipse不同步。 –
是的,你正確的。它顯示的文件與日食不同步。 – Anu