当前位置:网站首页>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());}}
边栏推荐
- 7.FileFilter interface
- Summary of steps and methods for installing and uninstalling test cases that you must read
- 接口开发规范及测试工具的使用
- 关于一次性通过CISSP考试的一点经验分享
- 软件测试外包公司怎么样?有什么好处和坏处?为什么没人去?
- 电脑硬件基础知识科普
- A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)
- 软件测试个人求职简历该怎么写,模板在这里
- JS报错-Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on...
- 2. Byte stream
猜你喜欢
What are the basic concepts of performance testing?What knowledge do you need to master to perform performance testing?
Cisco common basic configuration of common commands
What does the test plan include?What is the purpose and meaning?
软件测试个人求职简历该怎么写,模板在这里
软件测试面试题目:请你列举几个物品的测试方法怎么说?
字符串
软件测试分析流程及输出项包括哪些内容?
命令行查询数据库
白盒测试的概念、目的是什么?及主要方法有哪些?
一篇文章让你彻底搞懂关于性能测试常见术语的定义
随机推荐
A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)
软件测试流程包括哪些内容?测试方法有哪些?
Anti App so层对抗分析
Another implementation of lateral view explode
本体开发日记02-sparql简单查询
本体开发日记05-努力理解SWRL(Usage Suggestions)
Onnx - environment build 】 【 tensorrt
[Personal study summary] CRC verification principle and implementation
第三方免费开放API 获取用户IP 并查询其地理位置
安装torch_sparse失败解决方法
seata处理分布式事务
全网最全的软件测试基础知识整理(新手入门必学)
[Environmental Construction] tensorrt
The div simulates the textarea text box, the height of the input text is adaptive, and the word count and limit are implemented
一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
使用Protege4和CO-ODE工具构建OWL本体的实用指南-1.3版本(4.Building An OWL Ontology)
本体开发日记05-努力理解SWRL(上)
What are the basic concepts of performance testing?What knowledge do you need to master to perform performance testing?
7.Collections工具类
static_assert报错为什么?