title: How get timestamp on the file inside the gzip in Java
body: <p>I would like to preserve the timestamp of the file that is extracted from a gzip file in Java.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>   public void gunzipFile(String zipFile, String newFile) {
      System.out.println("zipFile: " + zipFile);
      final int bufferSize = 1024;
      try {
          FileInputStream fis = new FileInputStream(zipFile);
          BufferedInputStream bis = new BufferedInputStream(fis);
          GZIPInputStream gis = new GZIPInputStream(bis);
          FileOutputStream fos = new FileOutputStream(newFile);
          final byte[] buffer = new byte[bufferSize];
          int len = 0;
          while ((len = gis.read(buffer)) != -1) {
              fos.write(buffer, 0, len);
          }
          //close resources
          fos.close();
          gis.close();
      } catch (IOException e) {
          System.out.println("exception caught");
      }
  }
  </code></pre>