Java I';我试图向属性添加键、值,但它不起作用。请帮帮我

Java I';我试图向属性添加键、值,但它不起作用。请帮帮我,java,properties,key-value,Java,Properties,Key Value,我正在尝试向属性添加键、值,但它不保存 请帮帮我 Properties message_properties=new Properties(); InputStream is = this.getClass().getResourceAsStream("/resource/messages.properties"); message_properties.load(is); message_properties.setProperty("key1", "value1"); message_p

我正在尝试向属性添加键、值,但它不保存

请帮帮我

Properties message_properties=new Properties();  
InputStream is = this.getClass().getResourceAsStream("/resource/messages.properties");
message_properties.load(is);
message_properties.setProperty("key1", "value1");
message_properties.store(outputStream,null);

必须使用inputStream读取属性文件,使用outputStream写入文件

Properties prop = new Properties();

//read using input stream
InputStream in = getClass().getResourceAsStream("file location");
prop.load(in);
in.close();

//set property
prop.setProperty("key","value");

//store using output stream
prop.store(new FileOutputtream("File_Location");

你需要告诉我们出了什么问题?否则我们将如何帮助您。欢迎来到SO,“它不起作用”并没有阐明zour的问题是什么。请务必阅读:
outputStream
来自何处的消息属性类型?你在哪里关门?