Java Unzip to Folder unzip(String inFilePath)

Here you can find the source of unzip(String inFilePath)

Description

unzip

License

Open Source License

Declaration

public static String unzip(String inFilePath) throws FileNotFoundException, IOException 

Method Source Code

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

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;

public class Main {
    public static String unzip(String inFilePath) throws FileNotFoundException, IOException {
        GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(inFilePath));

        String outFilePath = inFilePath.replace(".gz", "");
        OutputStream out = new FileOutputStream(outFilePath);

        byte[] buf = new byte[1024];
        int len;/*w ww. ja  v a  2  s.c o m*/
        while ((len = gzipInputStream.read(buf)) > 0)
            out.write(buf, 0, len);

        gzipInputStream.close();
        out.close();

        //new File(inFilePath).delete();

        return outFilePath;
    }
}

Related

  1. unzip(String archive, String out_dir)
  2. unZip(String baseDir, InputStream is)
  3. unzip(String compressedStr)
  4. unzip(String file, String destinationdir)
  5. unzip(String filePath, String unzipPath)
  6. unzip(String inFilePath, String outFilePath)
  7. unzip(String inputZipPath, String destinationDirectory)
  8. unzip(String path, int buffer)
  9. unZip(String pathDest, BufferedInputStream buffInputStream)