从属性文件中删除键和值?

har*_*tps 18 java properties properties-file

我想删除存储在属性文件中的键和值.我怎样才能做到这一点????

Bal*_*usC 38

首先load()它使用java.util.PropertiesAPI.

Properties properties = new Properties();
properties.load(reader);
Run Code Online (Sandbox Code Playgroud)

然后你可以使用这个remove()方法.

properties.remove(key);
Run Code Online (Sandbox Code Playgroud)

最后store()它到文件.

properties.store(writer, null);
Run Code Online (Sandbox Code Playgroud)

也可以看看: