I'm trying to save a JDOM document as gzipped XML, but am getting a "JDOMParceException: Premature end of file" when I try to load the document back into my application. Any suggestions? I know that the document is well formed, because I can save and reload it successfully if I don't try to gzip it.
Here's a snippet showing how I'm currently creating the compressed file:
and here's my attempt to load the file back into my application:Code:private Document _doc; // Note: Document creation code not included here XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); // I've tried with and without this statement FileOutputStream fos = new FileOutputStream(absPath); GZIPOutputStream gzos = new GZIPOutputStream(fos); xmlOutput.output(_doc, gzos);
Thank youCode:SAXBuilder parser = new SAXBuilder(); FileInputStream fis = new FileInputStream(absPath); GZIPInputStream gzis = new GZIPInputStream(fis); _doc = parser.build(gzis);




Reply With Quote
