Java Ungzip File unGzip(File inFile, File outFile)

Here you can find the source of unGzip(File inFile, File outFile)

Description

Uncompresses a Gzipped file

License

Open Source License

Parameter

Parameter Description
inFile a parameter
outFile a parameter

Exception

Parameter Description
FileNotFoundException an exception
IOException an exception

Declaration

public static void unGzip(File inFile, File outFile) throws FileNotFoundException, IOException 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    /**//from w w  w . ja v  a2 s .  c  o  m
     * Uncompresses a Gzipped file
     * @param inFile
     * @param outFile
     * @throws FileNotFoundException
     * @throws IOException
     */
    public static void unGzip(File inFile, File outFile) throws FileNotFoundException, IOException {
        GZIPInputStream gIn = new GZIPInputStream(new FileInputStream(inFile));
        FileOutputStream fos = new FileOutputStream(outFile);
        byte[] buffer = new byte[100000];
        int len;
        while ((len = gIn.read(buffer)) > 0) {
            fos.write(buffer, 0, len);
        }

        gIn.close();
        fos.close();
    }
}

Related

  1. ungzip(File gzip, File toDir)
  2. unGzip(File sourceZipFile, String destFolder, String destFile)
  3. unGzip(final File compressedInputFile, final File outputDir)
  4. unGzip(final File inputFile, final File outputDir)
  5. ungzip(InputStream ins)