Android ZipInputStream Save unzipEntry(ZipInputStream zis, File targetFile)

Here you can find the source of unzipEntry(ZipInputStream zis, File targetFile)

Description

Unzip one entry

Parameter

Parameter Description
zis a parameter
targetFile a parameter

Exception

Parameter Description
IOException an exception

Declaration

private static final File unzipEntry(ZipInputStream zis, File targetFile)
        throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.util.zip.ZipInputStream;

public class Main {
    private static final int BUFFER_SIZE = 1024 * 2;

    /**/* w  ww  .  j a  va  2s  .  c  o m*/
     * Unzip one entry
     * 
     * @param zis
     * @param targetFile
     * @return
     * @throws IOException
     */
    private static final File unzipEntry(ZipInputStream zis, File targetFile)
            throws IOException {
        FileOutputStream fos = new FileOutputStream(targetFile);

        byte[] buffer = new byte[BUFFER_SIZE];
        int len = 0;
        while ((len = zis.read(buffer)) != -1) {
            fos.write(buffer, 0, len);
        }

        return targetFile;
    }
}

Related

  1. upzip(ZipInputStream zip, String destPath)
  2. unzipEntry(ZipInputStream zis, File targetFile)