java append a string to file
File file = new File("append.txt");
FileWriter fr = new FileWriter(file, true); // parameter 'true' is for append mode
fr.write("data");
fr.close();
3.6
5
try {
Files.write(Paths.get("myfile.txt"), "the text".getBytes(), StandardOpenOption.APPEND);
}catch (IOException e) {
//exception handling left as an exercise for the reader
}
Thank you!
5
0
Are there any code examples left?
New code examples in category Java