1
2File file = new File("append.txt");
3FileWriter fr = new FileWriter(file, true); // parameter 'true' is for append mode
4fr.write("data");
5fr.close();
6
1try {
2 Files.write(Paths.get("myfile.txt"), "the text".getBytes(), StandardOpenOption.APPEND);
3}catch (IOException e) {
4 //exception handling left as an exercise for the reader
5}