James Raitsev
James Raitsev

Reputation: 96421

org.dom4j.DocumentException: Stream closed Nested exception: Stream closed

When parsing valid XML file

private static boolean isXml(FileReader f) {

    try {
        saxReader.read(f);
    } catch (DocumentException e) {
        logger.warn("  - File is not XML: " + e.getMessage(), e);
        return false;
    }

    return true;
}

I can't quite understand though, why that is and can't find a java doc explaining this.

Have you seen something like this before? This exception thrown on a valid XML file that is:

org.dom4j.DocumentException: Stream closed Nested exception: Stream closed
    at org.dom4j.io.SAXReader.read(SAXReader.java:458)
    at org.dom4j.io.SAXReader.read(SAXReader.java:353)

Upvotes: 1

Views: 1306

Answers (1)

user207421
user207421

Reputation: 310957

The FileReader was already closed before you called the method.

Upvotes: 1

Related Questions