gpt4 book ai didi

java - 在 SAX 解析器中解析大型 XML 文件时没有内存的异常

转载 作者:行者123 更新时间:2023-11-30 08:14:33 25 4
gpt4 key购买 nike

我读过一些关于使用 SAX 解析器在 Java 中解析 XML 文件相对于使用 DOM 的优势的文章。最吸引我的(如讨论的 here )是

Sax is suitable for large XML File and The SAX parser does not loads the XML file as a whole in the memory.

但是现在我已经使用 SAX 编写了一个解析器来从一个 XML 文件中为一个几乎 1.4 GB 的大文件派生实体,它会生成以下异常。

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; The parser has encountered more than "64,000" entity expansions in this document; this is the limit imposed by the application.

如果整个文件没有加载到内存中,内存有什么问题。

我该如何解决这个问题?

最佳答案

使用 JVM 参数更改实体扩展限制:

-DentityExpansionLimit=1000000

关于java - 在 SAX 解析器中解析大型 XML 文件时没有内存的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29420795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com