So in my program I have a
private BufferedWriter logWriter;
logWriter = new BufferedWriter(new FileWriter(logFile));
public void log(String logTXT)
logWriter.write(logTXT + "\n");
} catch(Exception e)
Example of how to append to the end of a file.
FileWriter fw = new FileWriter("outfilename", true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw); out.println("the text"); out.println("more text");
The above will peform a
flush() for you automatically, you can either
flush() yourself or do the above.
The alternative to both would require multiple open and close operations. If this worked for you, please select it as the answer and upvote :)