小编Jho*_*hon的帖子

以比在Android中使用java.util.zip更快的方式解压缩文件

我需要在android中解压缩2.5mb(1087文件 - *.html,*.css和*.db)的.zip文件,我使用java.util.zip,它工作正常,但我需要提高性能,解压过程持续1.10分钟,我需要减少这个时间.我已经按照一些建议来改进性能,例如:

  • 使用BufferedInputStream,FileOutputStream和BufferedOutputStream.
  • 阅读块中的zip:

byte data [] = new byte [2048]; while((counter = bisMediaFile.read(data,0,2048))!= -1){bosMediaFile.write(data,0,counter); }

有没有办法改善我的代码?我正在搜索第三方zip程序以编程方式使用,例如我尝试了7ZipJBinding,但它看起来像android不支持这个,因为我引用了sevenzipjbinding.jar和sevenzipjbinding-AllPlatforms.jar但我得到一个错误:"Native在sevenzipjbinding-AllPlatforms中检测到的库".在7zip主页上有MAC,Windows,Linux版本,但我没有看到任何关于android的内容.你能推荐任何其他库来解压android中的文件吗?

这是我的所有代码:

public static void processZipFile(String strBinaryPath,String strExtractPath, String strDestinationDBPath) throws Exception
{
    ZipFile zipInFile = null;
    try
    {
        if (strExtractPath != null)
        {
            zipInFile = new ZipFile(strBinaryPath);
            for (Enumeration<? extends ZipEntry> entries = zipInFile.entries(); entries.hasMoreElements();)
            {
                ZipEntry zipMediaEntry = entries.nextElement();
                if (zipMediaEntry.isDirectory())
                {
                    File mediaDir = new File(String.format("%s\\%s", strExtractPath, zipMediaEntry.getName()));
                    mediaDir.mkdirs();
                }
                else
                {
                        BufferedInputStream bisMediaFile = null;
                        FileOutputStream fosMediaFile = null; …
Run Code Online (Sandbox Code Playgroud)

performance android 7zip unzip

6
推荐指数
1
解决办法
4355
查看次数

标签 统计

7zip ×1

android ×1

performance ×1

unzip ×1