添加或更新值时属性文件重置 (Java)
我将用户数据(没什么重要的,只是用户ID和XP金额/级别)存储在属性文件中。使用prop.store(输出,注释)
时,它会完全重置文件,然后存储添加的数据。如何在不重置整个文件的情况下添加数据?
I'm storing user data (nothing important, just user ID and xp amount/level) in a properties file. When using prop.store(output, comment)
it resets the file completely and then stores the added data. How can I add data without it resetting the entire file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次使用
store()
方法时,它都会删除旧数据并写入新数据。为了防止这种情况发生,您必须首先加载数据,然后使用要添加的新数据恢复它。
此代码片段可能会帮助您:
Each time you use the
store()
method, it removes the old data and writes the new data.To prevent this from happening, you must first load your data and then restore it with new data that you want to add.
This code snippet may help you: