/** * ?刪除文件夾里面的所有文件 * ?@param ?path ?String ?文件夾路徑 ?如 ?c:/fqf */public static void ?delAllFile(String ?path) ?{ ? ?File ?file ?= ?new ?File(path); ? ?if ?(!file.exists()) ?{ ? ? ? ?return; ? ?} ? ?if ?(!file.isDirectory()) ?{ ? ? ? ?return; ? ?} ? ?String[] ?tempList ?= ?file.list(); ? ?File ?temp ?= ?null; ? ?for ?(int ?i ?= ?0; ?i ?< ?tempList.length; ?i++) ?{ ? ? ? ?if ?(path.endsWith(File.separator)) ?{ ? ? ? ? ? ?temp ?= ?new ?File(path ?+ ?tempList[i]); ? ? ? ?} ? ? ? ?else ?{ ? ? ? ? ? ?temp ?= ?new ?File(path ?+ ?File.separator ?+ ?tempList[i]); ? ? ? ?} ? ? ? ?if ?(temp.isFile()) ?{ ? ? ? ? ? ?temp.delete(); ? ? ? ?} ? ? ? ?if ?(temp.isDirectory()) ?{ ? ? ? ? ? ?//先刪除文件夾里面的文件 ? ? ? ? ? ?delAllFile(path+"/"+ ?tempList[i]); ? ? ? ? ? ?/*//再刪除空文件夾 ? ? ? ? ? ?delFolder(path+"/"+ ?tempList[i]);*/ ? ? ? ?} ? ?}}我這邊找了一個(gè),寫著說是能刪除多個(gè)文件,但我運(yùn)行了只能刪除一個(gè),會(huì)的麻煩教教我,謝謝啦
java中刪除一個(gè)文件夾下的所有文件
qq_Dreamy_舊城_0
2017-12-04 16:26:34