If we use StringBuilder as the buffer of BufferedWriter, we need to make
StreamEncoder and all CharsetEncoders support write(StringBuilder) to achieve
better performance. There are many CharsetEncoders here, and this change is too
much.
And there is a scenario where performance will be degraded.
The BufferedWriterBench I added in PR 26022 can be configured to see the
performance of different encodings.
We can run the following command to see the performance of different encodings
on different content. The test numbers show that the performance of
BufferedWriter::write(String) is improve
Both Writer and CharsetEncoder are designed for char[]. Converting
BufferedWriter to use byte[] value + byte coder like StringBuilder will also
require redundant encoding conversion when using LATIN1 String, and the
performance will not be good.
--