【发布时间】:2016-06-27 06:42:24
【问题描述】:
我正在尝试让我的游戏将分数保存到一个文本文件中,稍后我想从中读取。但是我似乎无法将我的分数实际存储在文件中?
此外,我最终希望能够只存储前 10 个分数,所以如果文件中的分数高于 1,则覆盖分数?解决此问题的最佳方法是什么?
谢谢!
public void saveGame(Integer score){
try {
OutputStreamWriter osw = new OutputStreamWriter(getGame().getFileIO().writeFile("storetxt.txt"));
osw.write(score);
osw.close();
}
catch (IOException e){
Log.e("Exception", "Couldn't write to file: " + e.toString());
}
}
【问题讨论】:
标签: android android-studio outputstream fileoutputstream