public void writePlayerTurnActions(String action){
File file = new File(this.playerFileName);
try {
FileWriter writer = new FileWriter(this.playerFileName);
if(!file.exists()) {
file.createNewFile();
}
writer.write(action + "\n");
writer.close();
} catch (IOException e) {
System.out.println("Error writing to player output file");
}
}
Here is the method im using to keep updating a file depending on what occurs during the execution of the program. Im calling it by
instance.writePlayerTurnActions("1");
instance.writePlayerTurnActions("2");
instance.writePlayerTurnActions("3");
When running this code the file only contains a 3... and not 1, 2, 3 on seperate lines.
Any help appreciated as i'm so confused as to whats going wrong...