Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5663

trying to feed a zip file containing an XML one to a SAX parser ...

From lbrt chx _ gemale kom
Newsgroups comp.lang.java.programmer
Subject trying to feed a zip file containing an XML one to a SAX parser ...
Organization Acecape, Inc.
Organization Newshosting.com - Highest quality at a great price! www.newshosting.com
Message-ID <1308968121.989150@nntp.aceinnovative.com> (permalink)
Date 2011-06-25 02:15 +0000

Show all headers | View raw


~ 
 the simple code below I use to feed an XMLReader with compressed ".bz2" and ".gz"
~ 
 Since the zip file format is a container as well, I could imagine things are not that simple 
~ 
 How can you do the same (or a similar) thing with a zip file?
~ 
 thanks
 lbrtchx
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ 
 IFl = new File(aFlPth);
 aFlPth = IFl.getCanonicalPath();

 if(aFlPth.toLowerCase().endsWith(".gz")) {
  BfrRdr = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(IFl)), "UTF-8"));
 }
 else if (aFlPth.toLowerCase().endsWith(".bz2")) {
  BfrRdr = new BufferedReader(new InputStreamReader(new BZip2CompressorInputStream(new FileInputStream(IFl)), "UTF-8"));
 }
 else {
  BfrRdr = new BufferedReader(new InputStreamReader(new FileInputStream(IFl), "UTF-8"));
 }
// __ 
 SAXParserFactory SAXFctry = SAXParserFactory.newInstance();
 SAXFctry.setValidating(false);
 SAXFctry.setNamespaceAware(true);

 SchemaFactory SchmFctry = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
 SAXParser SAXPrsr = SAXFctry.newSAXParser();

 XMLRdr = SAXPrsr.getXMLReader();
 
// __ Register the content handler
 XMLRdr.setContentHandler(new DefaultHandler2());
// __ 
 lTm00 = System.currentTimeMillis();
 XMLRdr.parse(new InputSource(BfrRdr));
 System.err.println(TU.getElapsedTime(lTm00));
~ 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ 

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

 trying to feed a zip file containing an XML one to a SAX parser ... lbrt chx _ gemale kom - 2011-06-25 02:15 +0000
  Re: trying to feed a zip file containing an XML one to a SAX parser ... Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-06-24 20:11 -0700
  Re: trying to feed a zip file containing an XML one to a SAX parser ... Roedy Green <see_website@mindprod.com.invalid> - 2011-06-25 06:53 -0700

csiph-web