my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes is Document object closes the open file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "is Document object closes the open file" Watch "is Document object closes the open file" New topic

is Document object closes the open file

swapnel surade
Ranch Hand

Joined: Mar 05, 2009
Posts: 129

I'm using
SAXBuilder xmlFilebuilder = new SAXBuilder();
Document xmlDocument =;

to parse the XML file. But my application requires many hits to XML file.
the app I'm developing is getting one problem as "Too Many open files".
I'm using JDK 6.

I'm not closing the file explicitly as I don't have instance of file. I'm using SAXBuilder.
is Document object closes the object explicitly or not...

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12756
Well, Im not familiar with JDOM but generally we expect XML parsers to close the input stream no matter where it comes from.

You could always build a and use the build( inputstream ) then close the stream explicitly.

Consider Paul's rocket mass heater.
subject: is Document object closes the open file
Similar Threads
need to update entry in XML file.
JDOM parsing and memory
Parser Pooling with JDOM
Reading a xml file
How do I close an opened XML-file I just read?