Что вызывает родной сбой ZipFile? - PullRequest
0 голосов
/ 29 января 2019

Я встретил родной сбой, как показано ниже:

enter image description here

enter image description here

Кажетсясбой родного zipfile, я не знаю, почему это происходит.Код, использующий ZipFile, находится ниже

    private static boolean doUnzip(String zipPath, String outputDirectory, String onlyUnzipFile) {
    ZipFile zipFile = null;
    try {
        zipFile = new ZipFile(zipPath);
        Enumeration<? extends ZipEntry> zipList = zipFile.entries();
        ZipEntry ze = null;
        byte[] buffer = new byte[BUFFER_SIZE];

        while (zipList.hasMoreElements()) {
            ze = zipList.nextElement();

            if (ze.isDirectory()) {
                continue;
            }

            String name = ze.getName();
            if (name != null && name.indexOf("\\") != -1) {
                name = name.replaceAll("\\\\", File.separator);
            }
            String filePath = outputDirectory + File.separator + name;

            if ((!TextUtils.isEmpty(onlyUnzipFile))
                    && (filePath.indexOf(onlyUnzipFile) == -1)) {
                continue;
            }
            File file = createFileIfNotExists(filePath);

            OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
            InputStream is = new BufferedInputStream(zipFile.getInputStream(ze));

            int count = 0;
            while ((count = is.read(buffer, 0, BUFFER_SIZE)) != -1) {
                os.write(buffer, 0, count);
            }
            os.flush();

            is.close();
            os.close();

        }

    } catch (FileNotFoundException e) {
        return false;
    } catch (Throwable e) {
        e.printStackTrace();
        return false;
    } finally {
        if(zipFile != null) {
            try {
                zipFile.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    return true;
}

Кто-нибудь сталкивался с таким сбоем раньше?Я погуглил это, но не нашел много полезного материала.Кажется, это редкий случай.

...