title: How to extract .gz file Dynamically in Java?
body: <p>In <a href="http://www.newegg.com/Siteindex_USA.xml" rel="nofollow">http://www.newegg.com/Siteindex_USA.xml</a> lots of urls of .gz-files are given, like this:</p>
  
  <pre><code>&lt;loc&gt;
      http://www.newegg.com//Sitemap/USA/newegg_sitemap_product01.xml.gz
  &lt;/loc&gt;
  </code></pre>
  
  <p>I want to extract these dynamically. I don't want to store them locally, I just want to extract them and store the contained data in a database.</p>
  
  <p>Modify:</p>
  
  <p>I am getting exception </p>
  
  <pre><code>private void processGzip(URL url, byte[] response) throws MalformedURLException,
              IOException, UnknownFormatException {
  
          if (DEBUG) System.out.println("Processing gzip");
  
          InputStream is = new ByteArrayInputStream(response);
  
          // Remove .gz ending
          String xmlUrl = url.toString().replaceFirst("\\.gz$", "");
  
          if (DEBUG) System.out.println("XML url = " + xmlUrl);
  
          InputStream decompressed = new GZIPInputStream(is);
          InputSource in = new InputSource(decompressed);
          in.setSystemId(xmlUrl);         
          processXml(url, in);
          decompressed.close();
      }
  </code></pre>