[jdom-interest] JDOM and very large files

Elliotte Rusty Harold elharo at metalab.unc.edu
Fri Oct 10 05:31:50 PDT 2003


At 10:07 PM -0700 10/9/03, Daryl  Handley wrote:
>Hi everyone,
>
>I am trying to parse a very large file (1.3 Gb) using JDOM. I have used JDOM
>before with smaller files, but never large ones. It seems like the builder
>attempts to read the whole file into memory and build the document. Is there
>a way to read only part of the document into memory ? I only beed to read
>through the file sequentially, random access to parts of the doc is not
>important. Does anyone have any suggestions how to do this with JDOM ? Java
>in general ? Any other language ?
>

You might be better off using XOM. http://www.cafeconleche.org/XOM/ 
The NodeFactory class in XOM is designed to allow exactly this. You 
can process one element of your choice at a time, with all its 
children intact, and then throw it away so it doesn't eat up memory 
before you process the next element. It's a very nice middle ground 
between pure streaming APIs such as SAX, that provide too little 
information in one method call, and pure tree APIs like JDOM, that 
provide too much. XOM lets you set the granularity at you which you 
want to process your documents.

-- 

   Elliotte Rusty Harold
   elharo at metalab.unc.edu
   Processing XML with Java (Addison-Wesley, 2002)
   http://www.cafeconleche.org/books/xmljava
   http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA



More information about the jdom-interest mailing list