Java Ungzip File ungzipFile(String inputFileName, String outputFileName)

Here you can find the source of ungzipFile(String inputFileName, String outputFileName)

Description

ungzip File

License

Open Source License

Declaration

public static boolean ungzipFile(String inputFileName,
        String outputFileName) throws Exception 

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.util.zip.GZIPInputStream;

public class Main {

    public static boolean ungzipFile(String inputFileName,
            String outputFileName) throws Exception {
        GZIPInputStream in = null;
        FileOutputStream out = null;
        try {//from w  w w . j  ava 2 s  . c  om
            in = new GZIPInputStream(new FileInputStream(new File(
                    inputFileName)));
            out = new FileOutputStream(new File(outputFileName));

            final int BUFSIZ = 102400;
            byte inbuf[] = new byte[BUFSIZ];
            int n;
            while ((n = in.read(inbuf, 0, BUFSIZ)) != -1)
                out.write(inbuf, 0, n);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            if (in != null)
                in.close();
            if (out != null)
                out.close();
        }
    }
}

Related

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