Will not closing a stringwriter cause a leak?
The javadoc is quite explicit: Closing a StringWriter has no effect. And a quick look at the code confirms it: public void close() throws IOException { }
The javadoc is quite explicit: Closing a StringWriter has no effect. And a quick look at the code confirms it: public void close() throws IOException { }
I don’t think any of the existing answers really answer the question. The actual relationship between the two classes is an example of the adapter pattern. StringWriter implements all its Write… methods by forwarding on to an instance of StringBuilder that it stores in a field. This is not merely an internal detail, because StringWriter … Read more