在黑莓中写入文本文件
有什么办法可以使文本文件中的数据持久化吗?每次用户玩完游戏时,在我的程序中,他的名字和相应的分数都会写入文本文件。当下一位玩家到来时,前一位玩家将被覆盖。由于我是在写入模式下编写的,所以我不确定是否支持附加模式来在黑莓中保存此类分数...欢迎任何建议
is there any way out that we can make the data in text file persistent? everytime a user finishes playing a game, in my program his name and respective score is written to a text file. When the next player comes the previous one gets overwritten. since am writing in write mode, I am not sure whether append mode is supported to save scores of this sort in blackberry...any suggestions are welcome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确实应该使用 PersistentStore 来存储此类信息 - 它比尝试写入文件更容易使用并且可能更可靠。
但是,如果您坚持要写入文件,这里是打开文件进行追加的通用代码:
You should really use the PersistentStore to store this type of information - it's much easier to use and probably more reliable than trying to write files.
However, if you insist on writing files, here's the general code to open a file for appending: