What has been noted above is true. The different flavours of BufferWiter
's append()
method return a Writer
, which implements Appendable
, among others, thereby affording you the ability to chain calls. In addition, append()
allows you to pass a CharSequence
as well as a char
, as opposed to an int
, String
or char[]
, as with the write()
methods. All correct.
However, as the question states, an important issue to point out that the underlying behaviour of append()
is still much the same as that of write()
. Despite the somewhat misleading nomenclature, existing file content will be overwritten, not appended, unless your FileWriter
is instantiated otherwise:
try (var writer = new BufferedWriter(new FileWriter("myFile.txt", true));) {
writer.append("XXX").append("ZZZ");
}
In that sense I think the original question raises a valid point.