• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting an XML file from a JAR file

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I've been browsing through the forum but have not been able to find a solution to this problem.
I have a whole directory full of JAR files. Each JAR file has an XML file inside which I need to parse one by one (the JAR files are not in the ClassPath)
So far I've created my SAX Parse (which is working fine) and I've created a JAR tool that will extract the XML file from a JAR and store it as a byte[] in memory. Now how do I connect my byte[] with the SAXParser?
To parse one file that is not in a JAR I simply do this:

Which is working great. But since I don't have my XML file as a File object but only as a byte[] I am a bit stuck.
I would like to avoid having to extract the XML file to the harddisk and load it from there.
Really hope that someone can help as I've been spending the last eight hours trying to solve this with no luck.
Kind regards,
Allan
[ March 28, 2004: Message edited by: Allan Lykke Christensen ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's an overloaded SAXParser#parse(InputStream, HandlerBase) that you can use if you just wrap your byte[] into a java.io.ByteArrayInputStream
 
Allan Lykke Christensen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Lasse! That really helped.

Did it for me!
reply
    Bookmark Topic Watch Topic
  • New Topic