Никогда не поздно, я полагаю, использование вышеупомянутой расстегивания молнии действительно слишком медленное, поэтому я изменил его
, используя ниже класс
package com.example.epubdemo;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import android.util.Log;
public class DecompressFast {
private String _zipFile;
private String _location;
public DecompressFast(String zipFile, String location) {
_zipFile = zipFile;
_location = location;
_dirChecker("");
}
public void unzip() {
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + ze.getName());
if(ze.isDirectory()) {
_dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(_location + ze.getName());
BufferedOutputStream bufout = new BufferedOutputStream(fout);
byte[] buffer = new byte[1024];
int read = 0;
while ((read = zin.read(buffer)) != -1) {
bufout.write(buffer, 0, read);
}
bufout.close();
zin.closeEntry();
fout.close();
}
}
zin.close();
Log.d("Unzip", "Unzipping complete. path : " +_location );
} catch(Exception e) {
Log.e("Decompress", "unzip", e);
Log.d("Unzip", "Unzipping failed");
}
}
private void _dirChecker(String dir) {
File f = new File(_location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
}
}
ИСПОЛЬЗОВАНИЕ
// save zip file in your internal storage directly not in any sub folder( if using any sub folder give below path correctly)
String zipFile = Environment.getExternalStorageDirectory() + "/the_raven.zip"; //your zip name
String unzipLocation = Environment.getExternalStorageDirectory() + "/unzippedtestNew/"; //your unzip directory name
DecompressFast df= new DecompressFast(zipFile, unzipLocation);
df.unzip();
НЕ ЗАБУДЬТЕ ПРОЧИТАТЬ И НАПИСАТЬ РАЗРЕШЕНИЯ
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />