I'm looking for an easy and save solution to append text to a existing file in Java 8 using a specified Charset cs
. The solution which I found here deals with the standard Charset
which is a no-go in my situation.
One way it to use the overloaded version of Files.write
that accepts a Charset:
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
List<String> lines = ...;
Files.write(log, lines, UTF_8, APPEND, CREATE);