Oracle JDK的ZipFileSystem是否支持ZIP64?

时间:2016-06-10 03:39:09

标签: java zip nio

我们遇到了一个奇怪的异常' java.util.zip ZipException:loc:wrong sig - > 72ce7495'使用以下代码解压缩一个巨大的zip文件(大于4G)时:

final URI jobFileSystem = URI.create("jar:" + file.toUri().toString());
try (final FileSystem resFileSystem = FileSystems.newFileSystem(jobFileSystem, ImmutableMap.of());
            final Stream<Path> zipEntryFilePaths = Files.walk(resFileSystem.getPath("/"))) {

        return zipEntryFilePaths
                .parallel()
                .filter(Files::isRegularFile)
                .map(zipEntryFilePath -> {
            final String zipEntryFileName = getEntryFileName(zipEntryFilePath);
            try {
                final Path targetFilePath = targetFolder.resolve(zipEntryFileName);

                // Code for extracting zipEntryFilePath to targetFilePath
                // ...
                // ....

                return packageFilePath;
            } catch (IOException ioe) {
                throw new UncheckedIOException(ioe);
            }
        }).distinct().collect(Collectors.toList());
    } 

巨大的zip文件是在linux机器上使用zip命令创建的。 zip命令是使用ZIP64_SUPPORT选项编译的。

Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
Currently maintained by E. Gordon.  Please send bug reports to
the authors using the web page at www.info-zip.org; see README for details.

Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
as of above date; see http://www.info-zip.org/ for other sites.

Compiled with gcc 4.4.7 20120313 (Red Hat 4.4.7-16) for Unix (Linux ELF) on     Nov 10 2015.

Zip special compilation options:
    USE_EF_UT_TIME       (store Universal Time)
    SYMLINK_SUPPORT      (symbolic links supported)
    LARGE_FILE_SUPPORT   (can read and write large files on file system)
    ZIP64_SUPPORT        (use Zip64 to store large files in archives)
    UNICODE_SUPPORT      (store and read UTF-8 Unicode paths)
    STORE_UNIX_UIDs_GIDs (store UID/GID sizes/values using new extra field)
    UIDGID_NOT_16BIT     (old Unix 16-bit UID/GID extra field not used)
    [encryption, version 2.91 of 05 Jan 2007] (modified for Zip 3)

Encryption notice:
    The encryption code of this program is not copyrighted and is
    put in the public domain.  It was originally written in Europe
    and, to the best of our knowledge, can be freely distributed
    in both source and object forms from any country, including
    the USA under License Exception TSU of the U.S. Export
    Administration Regulations (section 740.13(e)) of 6 June 2002.

Zip environment options:
         ZIP:  [none]
      ZIPOPT:  [none]

我们应该提供什么选项来使ZipFileSystem正常使用大于4G的zip文件?非常感谢任何帮助或提示。

0 个答案:

没有答案