android 解压缩功能.

/**
     * 解压缩功能. 将zipFile文件解压到folderPath目录下.
     *
     * @throws Exception
     */
    public static int upZipPictureFile(File zipFile, String folderPath)
        throws ZipException, IOException
    {
    
        ZipFile zfile = new ZipFile(zipFile);
        Enumeration zList = zfile.entries();
        ZipEntry ze = null;
        byte[] buf = new byte[1024];
        while (zList.hasMoreElements())
        {
            ze = (ZipEntry)zList.nextElement();
            LogUtils.LOGI("upZipFile"+"**Log**", "ze.getName() = " + ze.getName());
            InputStream is = new BufferedInputStream(zfile.getInputStream(ze));
            OutputStream os = new BufferedOutputStream(new FileOutputStream(new File(folderPath, ze.getName())));;
                int readLen = 0;
                while ((readLen = is.read(buf, 0, 1024)) != -1)
                {
                    os.write(buf, 0, readLen);
                }
            is.close();
            os.close();
        }
        zfile.close();
        LogUtils.LOGI("upZipFile"+"**Log**", "finish");
        return 0;
    }

你可能感兴趣的:(android 解压缩功能.)