How to create a file — including folders — for a given path?

后端 未结 5 1282
旧时难觅i
旧时难觅i 2021-02-04 23:27

Am downloading a zip file from web. It contain folders and files. Uncompressing them using ZipInputstream and ZipEntry. Zipentry.getName

5条回答
  •  长情又很酷
    2021-02-05 00:18

    This is how I do it

    static void ensureFoldersExist(File folder) {
        if (!folder.exists()) {
            if (!folder.mkdirs()) {
                ensureFoldersExist(folder.getParentFile());
            }
        }
    }
    

提交回复
热议问题