使用docx4j进行docx比较时出现OutOfMemoryError

使用docx4j进行docx比较时出现OutOfMemoryError,第1张

使用docx4j进行docx比较时出现OutOfMemoryError

由于没有使用Docx4jDriver类,因此内存不足,这使得diff问题更容易解决,方法是先执行段落级别的diff。

像这样使用它:

        Body newerBody = ((document)newerPackage.getMaindocumentPart().getJaxbElement()).getBody();        Body olderBody = ((document)olderPackage.getMaindocumentPart().getJaxbElement()).getBody();        // 2. Do the differencing        java.io.StringWriter sw = new java.io.StringWriter();        Docx4jDriver.diff( XmlUtils.marshaltoW3CDomdocument(newerBody).getdocumentElement(),  XmlUtils.marshaltoW3CDomdocument(olderBody).getdocumentElement(),     sw);        // 3. Get the result        String contentStr = sw.toString();        System.out.println("Result: nn " + contentStr);        Body newBody = (Body) org.docx4j.XmlUtils  .unmarshalString(contentStr);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zaji/5500395.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-12
下一篇2022-12-12

发表评论

登录后才能评论

评论列表(0条)

    保存