I am using the following to write StringBuilder
into an existing text file.
FileUtils.writeStringToFile(file, sb.toString(), StandardCharsets.UTF_8);
The problem is that it overwrites the file where I just want to append sb.toString()
to the existing content of file
. How to workaround this issue?
It has been implemented in 2.1 version of Apache IO. To append string to the file just pass true as an additional parameter in functions:
example:
FileUtils.writeStringToFile(file, stringBuilder.toString(), true);