Android 解压缩ZIP文件操作
2015-05-18 20:22
218 查看
Android 解压缩ZIP文件操作,直接看代码:
/** * 解压缩zip文件,耗时操作,建议放入异步线程 * * */ public static void unzip(String targetPath, String zipFilePath) { try { int BUFFER = 2048; String fileName = zipFilePath; String filePath = targetPath; ZipFile zipFile = new ZipFile(fileName); Enumeration emu = zipFile.entries(); int i = 0; while (emu.hasMoreElements()) { ZipEntry entry = (ZipEntry) emu.nextElement(); if (entry.isDirectory()) { new File(filePath + entry.getName()).mkdirs(); continue; } BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry)); File file = new File(filePath + entry.getName()); File parent = file.getParentFile(); if (parent != null && (!parent.exists())) { parent.mkdirs(); } FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER); int count; byte data[] = new byte[BUFFER]; while ((count = bis.read(data, 0, BUFFER)) != -1) { bos.write(data, 0, count); } bos.flush(); bos.close(); bis.close(); } zipFile.close(); } catch (Exception e) { e.printStackTrace(); } }
相关文章推荐
- Android zip文件压缩解压缩
- Android zip文件压缩解压缩
- android解压zip到sdcard,并读取解压缩后文件中的xml特定信息,并保存到数据库
- Android zip文件压缩解压缩
- Android zip文件压缩解压缩
- 【Java】IO操作之使用zip包压缩和解压缩文件
- IO操作之使用zip包压缩和解压缩文件
- IO操作之使用zip包压缩和解压缩文件
- Android中用Java代码实现zip文件解压缩
- Android zip文件压缩解压缩
- Android zip文件压缩解压缩
- android压缩解压缩zip文件格式
- Android实现zip文件压缩及解压缩的方法
- CompressFile工具类使用,zip和rar文件解压缩与打包操作Java源代码
- android 解压缩mac zip压缩文件
- Java操作zip压缩和解压缩文件工具类
- Mac 解压zip文件错误:无法将"*.zip"解压缩到"" (错误 1-操作不被允许)
- Java操作zip压缩和解压缩文件工具类
- JAVA对文件的解压缩操作(利用java.util.zip*下的类)
- Java操作zip压缩和解压缩文件工具类