Hello all,
I have a java file that is an somewhat of a Event Handler.
I have a method inside that is called many times while program runs.
public void writeToFile(String string)
{
try
{
BufferedWriter writer = new BufferedWriter(new FileWriter("foo.txt"));
writer.append(string);
// writer.write(string); tried this also.
writer.flush();
writer.close();
}
catch(IOException io)
{
io.printStackTrace();
}
}
Problem is that I only get one line written to foo.txt, and each time I run the program it overwrites that one line with another value.
Expected results are at least 4 lines would be written in foo.txt each time I run program.
Any ideas?
TIA!