Here you can find the source of unzip(InputStream fileIn, File dirOut)
Parameter | Description |
---|---|
fileIn | a parameter |
dirOut | a parameter |
public static boolean unzip(InputStream fileIn, File dirOut)
//package com.java2s; //License from project: Open Source License import android.util.Log; 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 { /**/*from w w w.j a v a 2 s. c o m*/ * This is not tested on hierarchical zip files, currently only used on flat archives * @param fileIn * @param dirOut * @return true on success */ public static boolean unzip(InputStream fileIn, File dirOut) { try { ZipInputStream zin = new ZipInputStream(fileIn); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { Log.v("Decompress", "Unzipping " + ze.getName()); if (ze.isDirectory()) { throw new UnsupportedOperationException( "currently only flat archives are supported"); } else { FileOutputStream fout = new FileOutputStream(new File( dirOut, ze.getName())); for (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeEntry(); fout.close(); } } zin.close(); return true; } catch (Exception e) { Log.e("Decompress", "unzip", e); return false; } } }