德code在的Java XML大的base64:内存不足 [英] decode large base64 from xml in java: OutOfMemory
问题描述
我需要一个base64连接的XML文件的codeD元素写入到一个单独的文件。问题:文件可以很容易地达到100 MB的大小。 :Java堆空间java.lang.OutOfMemoryError每一个解决方案,我试图与结束。问题没有读一般xml或解码过程中,但以base64块的大小
I need to write a base64 encoded element of an xml file into a separate file. Problem: the file could easily reach the size of 100 MB. Every solution I tried ended with the "java.lang.OutOfMemoryError: Java heap space". The problem is not reading the xml in general or the decoding process, but the size of the base64 block.
我用JDOM,DOM4J和XMLStreamReader的访问XML文件。但是,只要我想访问相应元素的含量的base64我得到的提到的错误。我也尝试使用撒克逊的base64Binary的到八位功能的XSLT,当然具有相同的结果。
I used jdom, dom4j and XMLStreamReader to access the xml file. However, as soon as I want to access the base64 content of the respective element I get the mentioned error. I also tried an xslt using saxon's base64Binary-to-octets function, but of course with the same result.
有没有办法流的base64这一带codeD部分到一个文件中没有得到整个块中的一个单件?
Is there a way to stream this base64 encoded part into a file without getting the whole chunk in one single piece?
感谢您的提示,
安德烈亚斯
推荐答案
尝试StAX的API(的教程)。对于大的文本元素,你应该得到它,你需要推入流的Base64实现(像提到的skaffman)几个文本事件。
Try the StAX API (tutorial). For large text elements, you should get several text events which you need to push into a streaming Base64 implementation (like the one skaffman mentioned).
这篇关于德code在的Java XML大的base64:内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!