当前位置:网站首页>8. Recursively traverse and delete cases
8. Recursively traverse and delete cases
2022-08-09 09:33:00 【come here my bear】
Recursively traverse and delete folders case
package com.io.file;import java.io.File;/*** recursively traverse and delete*/public class Demo3 {public static void main(String[] args) {listDir(new File("E:\\Desktop\\aa"));deleteDir(new File("E:\\Desktop\\aa"));}// recursively traverse the folderpublic static void listDir(File dir){File[] files = dir.listFiles();System.out.println(dir.getAbsolutePath());if (files!=null&&files.length>0){for (File file : files) {if (file.isDirectory()){listDir(file); // recurse}else {System.out.println(file.getAbsolutePath());}}}}// recursively delete folderspublic static void deleteDir(File dir){File[] files = dir.listFiles();if (files!=null && files.length>0){for (File file : files) {if (file.isDirectory()){deleteDir(file); // recursive}else {// delete inner fileSystem.out.println(file.getAbsolutePath() + "delete" + file.delete());}}}// delete the outermost folder dirSystem.out.println(dir.getAbsolutePath() + "delete" + dir.delete());}}
边栏推荐
- web测试之功能测试常用的方法有哪几种?有什么要点要注意?
- 软件测试外包公司怎么样?有什么好处和坏处?为什么没人去?
- Do you know the principles of test cases and how to write defect reports?
- [Personal study summary] CRC verification principle and implementation
- Ontology Development Diary 05-Strive to Understand SWRL (Part 2)
- 5.转换流
- 电脑硬件基础知识科普
- seata处理分布式事务
- [Environmental Construction] tensorrt
- lateral view explode的另一种实现方式
猜你喜欢
How much do you know about the mobile APP testing process specifications and methods?
本体开发日记02-sparql简单查询
手机APP测试流程规范和方法你知道多少?
Ontology development diary 04 - to try to understand some aspects of protege
本体开发日记04-努力理解protege的某个方面
条件和递归
Ontology Development Diary 03-Understanding Code
黑盒测试常见错误类型说明及解决方法有哪些?
.equals ==
电脑硬件基础知识科普
随机推荐
软件测试面试常见问题及答案(发散思维、接口、性能、概念、)
Ontology Development Diary 03 - When debugging is in progress
.ts 音频文件转换成 .mp3 文件
自动化测试框架有哪几种?搭建的思路是什么?一篇文章让你彻底了解自动化
一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
China to create a domestic "Google Earth" clarity scary
使用Protege4和CO-ODE工具构建OWL本体的实用指南-1.3版本(4.Building An OWL Ontology)
[Machine Learning] Basics of Data Science - Basic Practice of Machine Learning (2)
接口性能测试方案设计方法有哪些?要怎么去写?
6.File类
白盒测试的概念、目的是什么?及主要方法有哪些?
软件测试面试中,面试官问你一些比较“刁难”的问题你会怎么回答
Summary of steps and methods for installing and uninstalling test cases that you must read
"The camera can't be used" + win8.1 + DELL + external camera + USB drive-free solution
QT sets the icon of the exe executable
功能自动化测试实施的原则以及方法有哪些?
5. Transform Streams
软件测试个人求职简历该怎么写,模板在这里
oracle查看表空间占用情况并删除多余表所占空间
7.FileFilter接口