How to unzip files recursively in Java?

后端 未结 9 2079
慢半拍i
慢半拍i 2020-11-27 03:10

I have zip file which contains some other zip files.

For example, the mail file is abc.zip and it contains xyz.zip, class1.java

9条回答
  •  被撕碎了的回忆
    2020-11-27 03:47

    One should CLOSE zip file after unzip.

    static public void extractFolder(String zipFile) throws ZipException, IOException 
    {
        System.out.println(zipFile);
        int BUFFER = 2048;
        File file = new File(zipFile);
    
        ZipFile zip = new ZipFile(file);
        try
        { 
           ...code from other answers ( ex. NeilMonday )...
        }
        finally
        {
            zip.close();
        }
    }
    

提交回复
热议问题