安卓客户端带密码压缩或者解压zip文件

来源:互联网 发布:tensorflow graph 编辑:程序博客网 时间:2024/04/27 22:19
这个是看的别人的文章,然后改过两行,拿到安卓上来用的
jar下载地址:http://download.csdn.net/detail/qq_24179679/9766252
操作类如下



具体调用
压缩:
ZipUtil zipUtil = new ZipUtil();
String src = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "DCIM" + File.separator + "aaa";
String dest = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "DCIM" + File.separator + "c.zip";
 zipUtil.ZipAddPass(src, dest, "jieyamima");

解压
ZipUtil zipUtil = new ZipUtil();
String dest = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM";
File mir = new File(dest);
if (mir.exists()) {
 try {
       File[] files = zipUtil.unzip(dest + "/c.zip", dest, "jieyamima");
        if (files != null) {
                            Log.e("-----------", files.length + "/");
                        }
                        for (int i = 0; i < files.length; i++) {
                            Log.e("-----------", files[i].getAbsolutePath() + "/" + files[i].getName());
                        }
                    } catch (ZipException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        Log.e("-------", "解压失败" + e.getMessage());
                    }
                }else {
                    Log.e("-------", "解压失败,DCIM文件夹不存在");
                }
0 0
原创粉丝点击