I want to save a score and a namehighscore in a filedatabase, but there are differntif an sql-exeption is thrown I want to temporary save the data in a file. The game has diffent modes that have differnt valuesand for each there is a highscore. I would like to have 2 lines for each mode, in which the name and the score are saved without overwritig other linesa savefile like this:
2 Bob 4 Luca 6 Celina 9 Bob I tried using "newLine()" to skipLine 1 is the lines I'm already using, but thenscore for gamemode 1 and in line 2 there is the data from those lines gets deletedname of the player. In addition,Line 3 and 4 for gamemode 2 and so on a restart differnt lines are used than before.
Writing partI have this Java Code:
Reading Part:The problem is, that the data of line 1 and 2 for example gets deleted if I want to save the data for line 3 and 4.
I tried using "newLine()" to skip the lines I'm already using, but then the data from those lines gets deleted. For example if I want to save the score 4 with the name Luca (line 3 and 4) the score of the gamemode 1 (2 and Bob, line 1 and 2) gets deletetd.
try{ highscoreData = new HighscoreData(); BufferedReader br = new BufferedReader(new FileReader("....SaveFile.txt")); highscoreData.setScore(Integer.parseInt(br.readLine())); <blank> highscoreData.setName(br.readLine()); <blank> br.close(); }catch (Exception e2) {4 }Luca