Writing a large XML file with Out Of Memory Error Java

I am developing an app for android, I need to create a rather large XML file.

I have tried this with a DOM document however because it resides in memory it throws an 'out of memory' error.

Can someone suggest an alternative solution? This is a XML file create from scratch.

Answers


I would write the XML to a Stream or Writer progressively as to traverse the data you want to turn into XML. This way you don't need much more memory than the original data.


Need Your Help

Why the servlet doesn't work?

java eclipse jsp servlets

All, I am the newbie into the Java web development, I am trying to implement a Servlet in my test. But I found the Servlet I created doesn't work . I didn't know whether I had missed anything. Please

Extract common class behaviour in a template

c++ templates generics

I observed that in my program I needed to make several classes use the following common pattern. The idea behind it is that resource_mgr maintains a list of reference-counted pointers to resource

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.