title: Extract .gz files in java
body: <p>I'm trying to unzip some .gz files in java. After some researches i wrote this method:</p>
  
  <pre><code>    public static void gunzipIt(String name){
  
      byte[] buffer = new byte[1024];
  
      try{
  
          GZIPInputStream gzis = new GZIPInputStream(new FileInputStream("/var/www/html/grepobot/API/"+ name + ".txt.gz"));
          FileOutputStream out = new FileOutputStream("/var/www/html/grepobot/API/"+ name + ".txt");
  
          int len;
          while ((len = gzis.read(buffer)) &gt; 0) {
              out.write(buffer, 0, len);
          }
  
          gzis.close();
          out.close();
  
          System.out.println("Extracted " + name);
  
      } catch(IOException ex){
          ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>when i try to execute it i get this error:
  java.util.zip.ZipException: Not in GZIP format</p>
  
  <p>how can i solve it? Thanks in advance for your help</p>