Java Ungzip File unGzip(File sourceZipFile, String destFolder, String destFile)

Here you can find the source of unGzip(File sourceZipFile, String destFolder, String destFile)

Description

un Gzip

License

Open Source License

Declaration

public static void unGzip(File sourceZipFile, String destFolder, String destFile) throws IOException 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

public class Main {
    private static final int BUFFER_SIZE = 8 * 1024;

    public static void unGzip(File sourceZipFile, String destFolder, String destFile) throws IOException {
        byte[] buffer = new byte[BUFFER_SIZE];

        FileInputStream fileIn = new FileInputStream(sourceZipFile);
        GZIPInputStream gZIPInputStream = new GZIPInputStream(fileIn);
        FileOutputStream fileOutputStream = new FileOutputStream(destFolder + "/" + destFile);

        int bytes_read;
        while ((bytes_read = gZIPInputStream.read(buffer)) > 0) {
            fileOutputStream.write(buffer, 0, bytes_read);
        }/*  www.j a  v a  2s  .  com*/

        gZIPInputStream.close();
        fileOutputStream.close();
    }
}

Related

  1. ungzip(File gzip, File toDir)
  2. unGzip(File inFile, File outFile)
  3. unGzip(final File compressedInputFile, final File outputDir)
  4. unGzip(final File inputFile, final File outputDir)
  5. ungzip(InputStream ins)
  6. ungzip(String gzipFile, String newFile)