Java Gunzip File gunzipFile(File inputGZippedFile, File outputFile)

Here you can find the source of gunzipFile(File inputGZippedFile, File outputFile)

Description

Gunzips one file from the inputGZippedFile and unzips to outputUnZippedFile

License

Open Source License

Declaration

public static void gunzipFile(File inputGZippedFile, File outputFile)
        throws java.io.FileNotFoundException, java.io.IOException 

Method Source Code

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

import java.io.File;

public class Main {
    /**//from  www. ja  v  a2  s .  co m
     * Gunzips one file from the inputGZippedFile and unzips to outputUnZippedFile
     */
    public static void gunzipFile(File inputGZippedFile, File outputFile)
            throws java.io.FileNotFoundException, java.io.IOException {
        java.util.zip.GZIPInputStream input = new java.util.zip.GZIPInputStream(
                new java.io.FileInputStream(inputGZippedFile));
        java.io.FileOutputStream output = new java.io.FileOutputStream(outputFile);
        //java.util.zip.GZIPOutputStream output = new java.util.zip.GZIPOutputStream();

        int buffersize = 100;
        byte[] buf = new byte[buffersize];
        int read = input.read(buf, 0, buffersize);

        while (read != -1) {
            output.write(buf, 0, read);
            read = input.read(buf, 0, buffersize);
        }

        input.close();
        output.close();
    }
}

Related

  1. gunzip(InputStream packedData, OutputStream unpackedData)
  2. gunzip(String compressedStr)
  3. gunzip(String inFile, String outFile)
  4. gunzipFile(File baseDir, File gzFile)
  5. gunzipFile(File file_input, File dir_output)
  6. ungzip(byte[] bytes)