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