当前位置:网站首页>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());}}边栏推荐
猜你喜欢

常用功能测试的检查点与用例设计思路

WAVE SUMMIT 2022深度学习开发者峰会

MVCC multi-version concurrency control

A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)
软件测试分析流程及输出项包括哪些内容?
![[Personal study summary] CRC verification principle and implementation](/img/99/ae0862522cd0d1c8f45604b9cd88c5.png)
[Personal study summary] CRC verification principle and implementation

字典
软件测试面试中,面试官问你一些比较“刁难”的问题你会怎么回答

.ts 音频文件转换成 .mp3 文件
本体开发日记03-排错进行时
随机推荐
搭建Tigase进行二次开发
"The camera can't be used" + win8.1 + DELL + external camera + USB drive-free solution
China to create a domestic "Google Earth" clarity scary
命令行查询数据库
4.字符流
可以写进简历的软件测试项目实战经验(包含电商、银行、app等)
自动化测试框架有哪几种?搭建的思路是什么?一篇文章让你彻底了解自动化
1.流的概念
STM32F103实现IAP在线升级应用程序
本体开发日记05-努力理解SWRL(Usage Suggestions)
vgg网络结构
LPP代码及其注释
Domestic with Google earth software, see the download 19th level high-resolution satellite images so easy!
2.字节流
div模拟textarea文本框,输入文字高度自适应,且实现字数统计和限制
软件测试面试中,面试官问你一些比较“刁难”的问题你会怎么回答
常用命令之思科常用基础配置
【分布式事务】
6. The File types
本体开发日记05-努力理解SWRL(RDF Concrete Syntax)