• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic