Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java IOException:膨胀文件的大小不匹配错误_Java_Android_Zip_Compression - Fatal编程技术网

Java IOException:膨胀文件的大小不匹配错误

Java IOException:膨胀文件的大小不匹配错误,java,android,zip,compression,Java,Android,Zip,Compression,在Android中,我需要解压一个zip文件,但在解压时,我最终得到一个IOException:膨胀文件的大小不匹配:6843932 v 0 我注意到在查看日志时,我看到一堆文件正在解压缩 geocoord/Canada/Nad27Nad83/123w53n3d.dac, 85472 bytes. Extracted 85472bytes. geocoord/Canada/Nad27Nad83/bc27v1_1.dac, 48032 bytes. Extracted 48032bytes. ge

在Android中,我需要解压一个zip文件,但在解压时,我最终得到一个IOException:膨胀文件的大小不匹配:6843932 v 0

我注意到在查看日志时,我看到一堆文件正在解压缩

geocoord/Canada/Nad27Nad83/123w53n3d.dac, 85472 bytes.
Extracted 85472bytes.
geocoord/Canada/Nad27Nad83/bc27v1_1.dac, 48032 bytes.
Extracted 48032bytes.
geocoord/Canada/Nad27Nad83/readme_Nad27ToNad83.txt, 646 bytes.
Extracted 646bytes.
geocoord/Canada/Nad83Csrs/readme_Nad83ToCsrs.txt, 593 bytes.
Extracted 593bytes.
geocoord/Canada/readme_canada.txt, 534 bytes.
Extracted 534bytes.
geocoord/coordsys.dty, 0 bytes.
我的代码非常简单:

private final int BYTE_SIZE = 4096;
private void unzip( String src, String target )
  {
  try
        {
        zipFile = new ZipFile(src);
        Enumeration<? extends ZipEntry> entries = zipFile.entries();
        while (entries.hasMoreElements())
            {
            ZipEntry entry = entries.nextElement();
            File entryDestination = new File(target, entry.getName());
            if (entry.isDirectory())
                entryDestination.mkdirs();
            else
                {
                entryDestination.getParentFile().mkdirs();
                InputStream in = zipFile.getInputStream(entry);
                OutputStream out = new FileOutputStream(entryDestination);
                Log.i("log_me", entry.getName() + ", " + entry.getSize() + " bytes.");
                int len = 0;
                long count = 0;
                byte[] arr = new byte[BYTE_SIZE];
                while ((len = in.read(arr)) > 0)
                    {
                    out.write(arr, 0, len);
                    count += len;
                    }
                out.flush();
                out.close();
                in.close();
                Log.i("log_me", "Extracted " + count + "bytes.");
                }
            }
        } 
    catch (Exception e)
        {
        e.printStackTrace();
        } 
    finally
        {
        try
            {                                                
            if (zipFile != null)
                zipFile.close();
            } 
        catch (Exception e)
            {
            e.printStackTrace();
            }
        }
    }
  }
压缩发生了什么事吗?看起来它可能没有正确压缩这些文件。(另一位同事写道)

我在看他的bash脚本,他写了这样的东西:

ZipArgs= -r -9 
@$(SrcRoot)bsitools\winx86\zip.exe $(ZipArgs) $(ZipTargetFile) $(ZipSourcePath) 
查看zip.exe文件时,会显示如下命令:

Copyright (C) 1990-1993 Mark Adler, Richard B. Wales, Jean-loup Gailly
and Kai Uwe Rommel. Type 'zip -L' for the software License.

Zip 2.0.1 (Sept 18th 1993). Usage:
zip [-options] [-b path] [-t mmddyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f   freshen: only changed files  -u   update: only changed or new files
-d   delete entries in zipfile    -m   move into zipfile (delete files)
-k   simulate PKZIP made zipfile  -g   allow growing existing zipfile
-r   recurse into directories     -j   junk (don't record) directory names
-0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
-1   compress faster              -9   compress better
-q   quiet operation              -v   verbose operation
-c   add one-line comments        -z   add zipfile comment
-b   use "path" for temp file     -t   only do files after "mmddyy"
-@   read names from stdin        -o   make zipfile as old as latest entry
-x   exclude the following names  -i   include only the following names
-F   fix zipfile (-FF try harder) -D   do not add directory entries
-T   test zipfile integrity       -L   show software license
-$   include volume label         -S   include system and hidden files
-h   show this help               -n   don't compress these suffixes
我认为
-r-9
不足以满足他的要求。似乎该文件没有将文件压缩到1级深度,而是将所有其他文件正确地压缩到后续目录中

编辑: 我注意到它打印出来:

test of %My_Path%geocoord.zip FAILED

zip error: Zip file invalid or insufficient memory (original files unmodified)
更新:


正在压缩的文件是符号链接文件和文件夹。它递归地遍历那些子文件夹,但文件本身只是复制PTR,而不是实际数据。

zip文件工具压缩符号链接,但符号链接显示了大小,因为它们很好,只是指针。因此大小已关闭。

您可以测试zip文件完整性(-T),以检查问题是否出在zip文件本身。它将根据该结果发布一个编辑。好了。。。zip文件已损坏我不知道为什么会损坏。看起来很奇怪。有没有关于是什么原因的线索?
test of %My_Path%geocoord.zip FAILED

zip error: Zip file invalid or insufficient memory (original files unmodified)