I'm getting that exception when reading an InputStream with JDOM's SAXBuilder's build
method:
InputStream bais = p_sendXML.getXml().getInputStream();
File myFile = new File(System.getProperty("java.io.tmpdir"), PREFIX+p_sendXML.getSessionId()+".xml");
IOUtils.copy(bais, new FileOutputStream(myFile));
LOGGER.debug("File save in: "+myFile.getAbsolutePath());
SAXBuilder builder = new SAXBuilder();
Document xmlDoc = builder.build(bais);
The File is correctly created and the XML inside is valid, so I shouldn't get this exception. There is a new line at the end of the XML file, if you are wondering.