Android InputStream Unzip extZipFile(InputStream is, String extPlace)

Here you can find the source of extZipFile(InputStream is, String extPlace)

Description

ext Zip File

Declaration

private static void extZipFile(InputStream is, String extPlace) 

Method Source Code

//package com.java2s;

import java.io.BufferedOutputStream;
import java.io.File;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import java.util.List;

import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
    private static final int BUFFER_SIZE = 8192;
    protected static byte buf[] = new byte[BUFFER_SIZE];
    private static List<Object> mTmpBuffer = new ArrayList<Object>();

    private static void extZipFile(InputStream is, String extPlace) {

        ZipInputStream in = new ZipInputStream(is);
        ZipEntry entry = null;// w  ww.j  ava2s .  c o m

        try {
            while ((entry = in.getNextEntry()) != null) {
                final String fullName = extPlace + entry.getName();
                if (entry.isDirectory()) {
                    File file = new File(fullName);
                    file.mkdirs();
                } else {
                    doOutputFile(in, fullName);
                    in.closeEntry();
                }
            }
        } catch (IOException e) {
        } finally {
            in = null;
        }
    }

    private static void doOutputFile(InputStream is, String filename)
            throws IOException, FileNotFoundException {
        FileOutputStream os = new FileOutputStream(filename);
        BufferedOutputStream bos = new BufferedOutputStream(os, BUFFER_SIZE);
        int len;
        while ((len = is.read(buf, 0, BUFFER_SIZE)) > 0) {
            bos.write(buf, 0, len);
        }
        bos.flush();
        bos.close();
        os.close();
        mTmpBuffer.add(os);
        mTmpBuffer.add(bos);
    }
}

Related

  1. decompress(InputStream is, OutputStream os)
  2. uncompress(InputStream inputStream)
  3. unpackZip(Context context, String s, InputStream is)
  4. readEntryAsWhatEverInternal( final ZipEntry entry, final InputStream unzippedInputStream)
  5. getZipFileList(InputStream is)
  6. decompressFile(File destFile, ZipInputStream zis)