1.最近的项目中有个需求,就是从oos上下载压缩包并且解压,对swf解密的需求。
2.解压过程中,要显示解压进度。解压成功后对swf文件解密。
3.关于显示解压进度的天坑:网上十片有八篇的方法:
/**
* @param zipFile 需要解压的文件
* @param filePath 解压后的文件目录
* @param isDeleteZip 是否删除解压包
* @throws ZipException
*/
private void unZipFileWithProgress(File zipFile, String filePath, boolean isDeleteZip) throws ZipException {
String usbOrTfPath = zipFile.getAbsolutePath();
ZipFile zFile = new ZipFile(zipFile);
zFile.setFileNameCharset("GBK");
if (!zFile.isValidZipFile()) {
if (zipFileImp != null) {
flag_unZip = false;
zipFileImp.copyAndUnPackFailed("文件不合法或不存在" + zipFile.getAbsolutePath());
}
Log.e("======", "文件不合法或不存在" + zipFile.getAbsolutePath());
return;
}
File destDir = new File(filePath); // ��ѹĿ¼
if (destDir.isDirectory() && !destDir.exists()) {
destDir.mkdir();
}
if (zFile.isEncrypted()) {
// zFile.setPassword(password); // 设置解压密码
}
// if (totalWork != 0) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
flag_unZip = true;
ProgressMonitor progressMonitor = zFile.getProgressMonitor();
int precentDone = 1;
boolean isFileeixst = false;
while (flag_unZip) {
Log.i("TTFFGG", "RRRR");