Reputation: 41
Document doc = DocumentBuilderFactory.newInstance().
newDocumentBuilder().
parse(new InputSource(new StringReader(xml)));
Upvotes: 2
Views: 550
Reputation: 21144
StringReader
extends Reader
, which implements Closeable
.
However, just by looking at the source code, you see what it does is basically irrelevant
public void close() {
str = null;
}
InputSource
doesn't implement Closeable
or AutoCloseable
, that means it is still the Reader
duty to close itself. Another implementation of Reader
might require that, however, so close it as standard.
One that might really require closing is FileReader
, which is also acceptable by InputSource
.
Upvotes: 1