0

Java を使用してファイルを解凍しようとしていますが、「ze」が null であるため、次のコードは while ループに入りません。ただし、同じファイルを 7zip アプリケーションを使用して解凍できます。誰かがなぜこれが起こっているのか教えてもらえますか?

試す{

        //get the zip file content
        ZipInputStream zis = 
            new ZipInputStream(new FileInputStream(zipFile));
        //get the zipped file list entry
        ZipEntry ze = zis.getNextEntry();

        while(ze!=null){

           String fileName = ze.getName();
           File newFile = new File(outputFolder + File.separator + fileName);

           System.out.println("file unzip : "+ newFile.getAbsoluteFile());

            //create all non exists folders
            //else you will hit FileNotFoundException for compressed folder
            new File(newFile.getParent()).mkdirs();

            FileOutputStream fos = new FileOutputStream(newFile);             

            int len;
            while ((len = zis.read(buffer)) > 0) {
            fos.write(buffer, 0, len);
            }

            fos.close();   
            ze = zis.getNextEntry();
        }

        zis.closeEntry();
        zis.close();

        System.out.println("Done");

    }catch(IOException ex){
       ex.printStackTrace(); 
    }
4

1 に答える 1