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");
File nomorlFile

在Android项目中,需要从云端下载并使用zip4j库解压压缩包,同时展示解压进度。然而,遇到一个棘手的问题:通过常见方法获取的解压进度不完整,甚至在U盘解压过程中意外断开连接也会错误地判断为解压成功。目前尚未找到理想的解决方案,可能的替代方法对压缩包内容有一定限制。
最低0.47元/天 解锁文章
1288

被折叠的 条评论
为什么被折叠?



