栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Android中以编程方式解压缩文件?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Android中以编程方式解压缩文件?

peno的版本进行了优化。性能的提高是可以察觉的。

private boolean unpackZip(String path, String zipname){ InputStream is;     ZipInputStream zis;     try      {         String filename;         is = new FileInputStream(path + zipname);         zis = new ZipInputStream(new BufferedInputStream(is));        ZipEntry ze;         byte[] buffer = new byte[1024];         int count;         while ((ze = zis.getNextEntry()) != null)          {  filename = ze.getName();  // Need to create directories if not exists, or  // it will generate an Exception...  if (ze.isDirectory()) {     File fmd = new File(path + filename);     fmd.mkdirs();     continue;  }  FileOutputStream fout = new FileOutputStream(path + filename);  while ((count = zis.read(buffer)) != -1)   {      fout.write(buffer, 0, count);    }  fout.close();      zis.closeEntry();         }         zis.close();     }      catch(IOException e)     {         e.printStackTrace();         return false;     }    return true;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/367717.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号