diff --git a/src/main/java/net/revelc/code/formatter/xml/lib/XmlDocumentFormatter.java b/src/main/java/net/revelc/code/formatter/xml/lib/XmlDocumentFormatter.java index 5dbf4d9..f27ba77 100644 --- a/src/main/java/net/revelc/code/formatter/xml/lib/XmlDocumentFormatter.java +++ b/src/main/java/net/revelc/code/formatter/xml/lib/XmlDocumentFormatter.java @@ -97,10 +97,9 @@ public String format(String documentText) { validateWellFormedness(documentText); } - Reader reader = new StringReader(documentText); FormatState state = new FormatState(); - try { + try (Reader reader = new StringReader(documentText)) { while (true) { reader.mark(1); int intChar = reader.read(); @@ -111,7 +110,6 @@ public String format(String documentText) { } copyNode(reader, state); } - reader.close(); } catch (IOException e) { logger.error("{}", e.getMessage()); logger.debug("", e);