java-刪除某目錄下所有文件


 1 private boolean delZSPic(String filePath) {
 2     boolean flag = true;
 3     if(filePath != null) {
 4         File file = new File(filePath);
 5         if(file.exists()) {
 6             File[] filePaths = file.listFiles();
 7             for(File f : filePaths) {
 8                 if(f.isFile()) {
 9                     f.delete();
10                 }
11                 if(f.isDirectory()){
12                     String fpath = f.getPath();
13                     delZSPic(fpath);
14                     f.delete();
15                 }
16             }
17         }
18     }else {
19         flag = false;
20     }
21     return flag;
22 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM