zip解压缩的使用
??? android中的解压缩方式和java中是一样的。以下为解压缩的方法代码
public void Ectract(String sZipPathFile, String sDestPath) { try { // 先指定压缩档的位置和档名,建立FileInputStream对象 FileInputStream fins = new FileInputStream(sZipPathFile); // 将fins传入ZipInputStream中 ZipInputStream zins = new ZipInputStream(fins); ZipEntry ze = null; byte ch[] = new byte[8192]; while ((ze = zins.getNextEntry()) != null) { File zfile = new File(sDestPath + ze.getName()); File fpath = new File(zfile.getParentFile().getPath()); if (ze.isDirectory()) { if (!zfile.exists()) zfile.mkdirs(); zins.closeEntry(); } else { if (!fpath.exists()) fpath.mkdirs(); FileOutputStream fouts = new FileOutputStream(zfile); int i; while ((i = zins.read(ch)) != -1) fouts.write(ch, 0, i); zins.closeEntry(); fouts.close(); } } fins.close(); zins.close(); } catch (Exception e){ e.printStackTrace(); } }
??