Java Utililty Methods Unzip to Folder

List of utility methods to do Unzip to Folder

Description

The list of methods to do Unzip to Folder are organized into topic(s).

Method

voidunzip(String archive, String out_dir)
unzip
ZipFile zipfile = new ZipFile(new File(archive));
Enumeration<? extends ZipEntry> en = zipfile.entries();
BufferedInputStream ins = null;
FileOutputStream outs = null;
File outFile = null;
while (en.hasMoreElements()) {
    try {
        ZipEntry entry = (ZipEntry) en.nextElement();
...
ArrayListunZip(String baseDir, InputStream is)
Extracts Zip file contents relative to baseDir
ArrayList files = new ArrayList();
ZipInputStream zis = new ZipInputStream(is);
while (true) {
    ZipEntry zipEntry = zis.getNextEntry();
    if (zipEntry == null)
        break;
    String entryName = zipEntry.getName();
    if (FILE_SEPARATOR.equalsIgnoreCase("\\")) {
...
Stringunzip(String compressedStr)
unzip
if (compressedStr == null) {
    return null;
ByteArrayOutputStream out = null;
ByteArrayInputStream in = null;
ZipInputStream zin = null;
String decompressed = null;
try {
...
voidunzip(String file, String destinationdir)
unzip
try {
    BufferedOutputStream dest = null;
    BufferedInputStream is = null;
    ZipEntry entry;
    ZipFile zipfile = new ZipFile(file);
    Enumeration<? extends ZipEntry> e = zipfile.entries();
    while (e.hasMoreElements()) {
        entry = (ZipEntry) e.nextElement();
...
voidunzip(String filePath, String unzipPath)
unzip
Enumeration entries;
ZipFile zipFile;
BufferedOutputStream out = null;
try {
    zipFile = new ZipFile(filePath);
    entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) entries.nextElement();
...
Stringunzip(String inFilePath)
unzip
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(inFilePath));
String outFilePath = inFilePath.replace(".gz", "");
OutputStream out = new FileOutputStream(outFilePath);
byte[] buf = new byte[1024];
int len;
while ((len = gzipInputStream.read(buf)) > 0)
    out.write(buf, 0, len);
gzipInputStream.close();
...
Stringunzip(String inFilePath, String outFilePath)
unzip
try {
    GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(inFilePath));
    OutputStream out = new FileOutputStream(outFilePath);
    byte[] buf = new byte[1024];
    int len;
    while ((len = gzipInputStream.read(buf)) > 0) {
        out.write(buf, 0, len);
    gzipInputStream.close();
    out.close();
    new File(inFilePath).delete();
    return outFilePath;
} catch (Exception e) {
    return null;
voidunzip(String inputZipPath, String destinationDirectory)
unzip
int BUFFER = 2048;
List zipFiles = new ArrayList();
File sourceZipFile = new File(inputZipPath);
File unzipDestinationDirectory = new File(destinationDirectory);
unzipDestinationDirectory.mkdir();
ZipFile zipFile;
zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
Enumeration zipFileEntries = zipFile.entries();
...
InputStreamunzip(String path, int buffer)
unzip
ZipFile zipfile;
try {
    zipfile = new ZipFile(path);
    Enumeration<? extends ZipEntry> e = zipfile.entries();
    BufferedInputStream is = null;
    ZipEntry entry;
    while (e.hasMoreElements()) {
        entry = (ZipEntry) e.nextElement();
...
voidunZip(String pathDest, BufferedInputStream buffInputStream)
Unzip a inputstream to a folder
new File(pathDest).mkdirs();
final int BUFFER = 2048;
BufferedOutputStream dest = null;
ZipInputStream zis = new ZipInputStream(buffInputStream);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
    int count;
    byte data[] = new byte[BUFFER];
...