• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I close an opened XML-file I just read?

 
Robert Jaeger
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I am using the following code to open XML files:

Now, after surfing on the webpages for a while(generated with jsp, content source is XML) Tomcat reported that too many documents are opened. I had to restart Tomcat.
So do I have to explicitly close the xml-files? How?
Thanks for your help,
Robert.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't be lazy, construct a FileReader first, after build, close it. This will solve too many files open problem. This is extremely important to busy websites. The resources will be used really quickly. You don't DOS (deny of services) by your own mistake. You original code will never close the valuable resources.
All 60 files are closed after build, but all Documents are still available for traversal.
See complete tested code here:
http://bobcat.webappcabaret.net/javachina/faq/xml_java_01.htm#jaxp_jdom_Q30
[ April 12, 2003: Message edited by: Roseanne Zhang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic