简体   繁体   中英

Jaxb to generate the XML directly to the OutputStream

I have a 500Mb csv file. I need to convert it into XML file.
I am using the Jaxb to created the xml file. It is working fine for small amout of data.
but for large amout of data like 300 mb it is throwing out of memory exception.
Can anyone tell me that How can I create each element and write it into a file
without creating the whole tree using the jaxb?"

Thanks Sonu

Converting csv to XML you should expect the size of data to be about 10x larger. I suggest you increase the heap size to 10 Gb if you want to use Jaxb for your whole file at once, possibly higher.

Another approach would be to convert one line of CSV at a time. You can still use Jaxb to do this, but you may find a one line println statement is much simpler. In this case, you can expect your program will use up to 10x the longest line. (Which might be a few KB)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM