如何修改属性文件中 4 个键值对中的 1 个?

How can I modify 1 key value pair out of 4 in a properties file?

我在属性文件中有 4 个键值对,我想修改 1 个键的值。如何在不影响其他键值对的情况下这样做?

这是加载属性文件、操作值并再次存储的示例。

try {
    File file = new File("YOUR PATH");

    FileInputStream input = new FileInputStream(file);
    Properties properties = new Properties();
    properties.load(input);
    input.close();

    properties.setProperty("YOUR_KEY", "YOUR_VALUE");

    FileOutputStream output = new FileOutputStream(file);
    properties.store(output, null);
    output.close();
} catch (Exception e) {
    e.printStackTrace();
}