Android InputStream Zip unZipTo(InputStream paramInputStream, String paramString)

Here you can find the source of unZipTo(InputStream paramInputStream, String paramString)

Description

un Zip To

Declaration

public static void unZipTo(InputStream paramInputStream,
            String paramString) throws Exception 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
    public static void unZipTo(InputStream paramInputStream,
            String paramString) throws Exception {
        File localFile1 = new File(paramString);
        if (!localFile1.exists())
            localFile1.mkdirs();//from  w ww  .  j  a va2  s.  c  o  m
        ZipInputStream localZipInputStream = new ZipInputStream(
                paramInputStream);
        while (true) {
            ZipEntry localZipEntry = localZipInputStream.getNextEntry();
            if (localZipEntry == null)
                break;
            String str1 = localZipEntry.getName();
            if (localZipEntry.isDirectory()) {
                String str2 = str1.substring(0, -1 + str1.length());
                new File(paramString + File.separator + str2).mkdirs();
                continue;
            }
            File localFile2 = new File(paramString + File.separator + str1);
            if (localFile2.exists())
                localFile2.delete();
            localFile2.createNewFile();
            FileOutputStream localFileOutputStream = new FileOutputStream(
                    localFile2);
            byte[] arrayOfByte = new byte[1024];
            while (true) {
                int i = localZipInputStream.read(arrayOfByte);
                if (i == -1)
                    break;
                localFileOutputStream.write(arrayOfByte, 0, i);
                localFileOutputStream.flush();
            }
            localFileOutputStream.close();
        }
        localZipInputStream.close();
    }
}

Related

  1. compress(InputStream is, OutputStream os)
  2. compress(InputStream is, OutputStream os)
  3. compress(InputStream is, OutputStream os)