Writer writer = new OutputStreamWriter(out, charset);
writer.write(in);
writer.flush();

OutputStreamWriter constuctor does unnecessary buffer allocation (8kb)

Given that it already has a string, maybe it can be avoided writing a string to the stream directly.

out.write(in.getBytes(charset));
out.flush();

It's used in plaintext endpoints through StringHttpMessageConverter

Here's approximate difference in time
| String Length | copy (ns/op) | copyOSW (ns/op) |
| ------------- | ------------ | --------------- |
| 10            | 4.314        | 311.848         |
| 100           | 9.187        | 310.556         |
| 1,000         | 35.274       | 569.202         |
| 10,000        | 545.262      | 1581.522        |
| 50,000        | 1833.014     | 6171.236        |
| 100,000       | 3341.869     | 11976.815       |

Comment From: pivotal-cla

@7fantasy7 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@7fantasy7 Thank you for signing the Contributor License Agreement!