1

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)
2
  • No. Java app running on Linux parsing an XML file Commented Mar 1, 2012 at 19:01
  • Okay, never mind then. There was this web page suggesting that it would not work on Android, producing the exact same exception. Commented Mar 1, 2012 at 19:08

1 Answer 1

1

The FileReader was already closed before you called the method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.