Java Ungzip decompressGzipFile(String gzipFile, String newFile)

Here you can find the source of decompressGzipFile(String gzipFile, String newFile)

Description

decompress Gzip File

License

Open Source License

Declaration

public static void decompressGzipFile(String gzipFile, String newFile) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    public static void decompressGzipFile(String gzipFile, String newFile) {
        try {/* w  ww.j a  v a  2s  .co  m*/
            FileInputStream fis = new FileInputStream(gzipFile);
            GZIPInputStream gis = new GZIPInputStream(fis);
            FileOutputStream fos = new FileOutputStream(newFile);
            byte[] buffer = new byte[1024];
            int len;
            while ((len = gis.read(buffer)) != -1) {
                fos.write(buffer, 0, len);
            }
            // close resources
            fos.close();
            gis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

Related

  1. decompressGZIP(String sourceFilename, String targetFilename)
  2. decompressGzipString(String gzipFile)