I have looked at countless forum posts and articles on how to write to files, but to no avail have I come across a useful one. I use, currently, a FileWriter declared with:
public FileWriter filewriter;
and then initated with
try {
filewriter = new FileWriter(textfile, true);
} catch (IOException e) {
e.printStackTrace();
}
and then I write to the file with:
try {
filewriter.write(string + "string");
filewriter.flush();
catch (IOException e) {
e.printStackTrace();
}
So how do I make it so that my writer willl NOT overwrite the current text, and WILL add new lines to the text.
For example (Try to use these as an example): I want to write the following
- Go to the town
- Then turn right
- Then go into the tavern
- Say hi to the old man in purple
So how do I do that writing COMPLETELY from Java. All instigated at different times, like whenever you click a button, the first line writes, whenever you click it again, it writes the second line, and so on.