How do I append the highscore into highscore.txt file at the correct position in descending order? The method uses readHighScore(int score) method created previously to find the line number where the record should be inserted. This is what I got so far:
public static void recordHighScore(String name, int score){
File file = new File("Test/highscore.txt");
FileWriter fwriter = new FileWriter(file, true);
try{
String userName = name+","+score;
fwriter.add(readHighScore(score), userName);
}catch(IOException io){
System.out.println("Missing File!");
}
/*Writes the high score into highscore.txt file, at the correct position (in descending order). This
method uses readHighScore( ) method to find the line number where the record should be
inserted.*/
}