I'm trying to write some code that will write certain variables to a text file and create a simple record system. So when a button is clicked the variables are calculated and written to a text file. How can I set it up so that when the button is clicked again and the variables change due to the new values, the new set of variables are written on a different line in the text file and don't simple overwrite the old ones. So there would be one record per line.
This is the code I have for the writer component of the programme so far:
try
{
FileWriter writer = new FileWriter("YachtClubRecords.txt");
writer.write(outputName);
writer.write(outputLength);
writer.write(durationType);
writer.write(outputCost);
writer.flush();
writer.close();
}
catch(IOException ioe)
{
System.out.println("IO Exception");
}
At the moment it obviously overwrites the previous record again and again. Thanks.