这两天研究了一下android下的解压所技术,略有所获,下面是解压缩的操作方法。 private void unZipMapCache(){ try { InputStream is = this.getAssets().open(ASSETS_NAME); ZipInputStream zis= new ZipInputStream(is); ZipEntry entry = null; while((entry = zis.getNextEntry()) != null){ File file = new File("/mnt/sdcard/",entry.getName()); if(entry.isDirectory()){ file.mkdirs(); continue; }else{ file.createNewFile(); OutputStream myOutput = new FileOutputStream(file); byte[] buffer = new byte[1024]; int count; while ((count = zis.read(buffer)) != -1) { myOutput.write(buffer, 0, count); } myOutput.close(); } } zis.close(); is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Android 解压zip文件
最新推荐文章于 2024-02-01 17:39:52 发布