1

こんにちは、私は中国の反対側にある太平洋の出身です。私の初歩的な英語を許してください。外国のウェブサイトのスクリーニングは、さらに多くの問題を引き起こします。

現在のプロジェクトでは zip4j を使用していますが、問題が発生します。これが私のコードです:

public static File [] unzip(File zipFile, String dest, String passwd) throws ZipException {
    ZipFile zFile = new ZipFile(zipFile);
    zFile.setFileNameCharset("GBK");
    if (!zFile.isValidZipFile()) {
        throw new ZipException("压缩文件不合法,可能被损坏.");
    }
    File destDir = new File(dest);
    if (destDir.isDirectory() && !destDir.exists()) {
        destDir.mkdir();
    }
    if (zFile.isEncrypted()) {
        zFile.setPassword(passwd.toCharArray());
    }
    zFile.extractAll(dest);

    List<FileHeader> headerList = zFile.getFileHeaders();
    List<File> extractedFileList = new ArrayList<File>();
    for(FileHeader fileHeader : headerList) {
        if (!fileHeader.isDirectory()) {
            extractedFileList.add(new File(destDir,fileHeader.getFileName()));
        }
    }
    File [] extractedFiles = new File[extractedFileList.size()];
    extractedFileList.toArray(extractedFiles);
    return extractedFiles;
}

この問題は、パッケージ ファイルを特定の数 (私のファイルは 2000) 以上圧縮すると発生します。myeclipse 開発ツールと tomcat サーバーを使用しました。

myeclipse でブレークポイントを使用しましたが、エラーは発生しませんでした。ブレークポイントを追加しないと、直接操作エラーが発生しました。

net.lingala.zip4j.exception.ZipException: Compressed file is not valid, can be damaged.
    at com.ninemax.cul.util.CompressUtil.unzip(CompressUtil.java:68)
    at com.ninemax.cul.util.CompressUtil.unzip(CompressUtil.java:38)
    at com.ninemax.cul.service.impl.SysShangChuanWenWuService.writeDataToDatabase(SysShangChuanWenWuService.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:311)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy48.writeDataToDatabase(Unknown Source)
    at com.ninemax.cul.action.web.UserUploadAction.uploadSuccess(UserUploadAction.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
4

1 に答える 1

0

抽出しようとしている ZIP ファイルを作成するために使用されるツールは何ですか?

ほとんどの場合、zip ファイルが破損しています。Winzip (Windows) や GUnzip (UNIX) などの解凍ツールを使用して解凍し、破損していないかどうかを確認してください。

破損していない場合、zip は暗号化されており、Zip4J でサポートされていない暗号化方式を使用してパスワードで保護されている可能性があります。たとえば、Zip4J は AES-256 ビットの Winzip 暗号化/復号化をサポートしていますが、AES-256 PKZIP 暗号化/復号化はサポートしていません。

于 2013-01-16T08:44:06.890 に答える