public static boolean unzip(String zipFilePath, String folderPath, String... pwd) {

        ZipFile zipFile;
        try {

            //创建压缩对象
            zipFile = new ZipFile(new File(zipFilePath));

            if (!zipFile.isValidZipFile()) {
                //压缩文件校验可用性失败
                new ZipException("Invalid archive").printStackTrace();
                return false;
            }


            if (zipFile.isEncrypted()) {
                if (pwd == null || pwd.length == 0) {
                    //需要密码访问
                    new ZipException("The password is required to access the io").printStackTrace();
                    return false;
                }

                zipFile.setPassword(pwd[0]);
            }
        } catch (ZipException e) {
            e.printStackTrace();
            return false;
        }


        //创建目标位置
        File filePath;
        try {
            filePath = new File(folderPath);
            if (filePath.isDirectory() && !filePath.exists()) {
                filePath.mkdirs();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

        try {
            zipFile.extractAll(folderPath);
        } catch (ZipException e) {
            e.printStackTrace();
            return false;
        }

        return true;
    }
public static boolean unzip ( String zipFilePath , String folderPath , String ... pwd ) { ZipFile zipFile ; try { zipFile = new ZipFile ( new File ( zipFilePath ) ) ; if ( ! zipFile . isValidZipFile ( ) ) { new ZipException ( "Invalid archive" ) . printStackTrace ( ) ; return false ; } if ( zipFile . isEncrypted ( ) ) { if ( pwd == null || pwd . length == 0 ) { new ZipException ( "The password is required to access the io" ) . printStackTrace ( ) ; return false ; } zipFile . setPassword ( pwd [ 0 ] ) ; } } catch ( ZipException e ) { e . printStackTrace ( ) ; return false ; } File filePath ; try { filePath = new File ( folderPath ) ; if ( filePath . isDirectory ( ) && ! filePath . exists ( ) ) { filePath . mkdirs ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } try { zipFile . extractAll ( folderPath ) ; } catch ( ZipException e ) { e . printStackTrace ( ) ; return false ; } return true ; }
解压压缩文件
<p>Function: unzip</p>
<p>Description: </p>

@param zipFilePath    压缩文件位置
@param folderPath 解压文件夹位置
@param pwd            解压密码(如果有)
@return
@author acexy@thankjava.com
@date 2016年8月12日 下午4:08:54
@version 1.0