当前位置:网站首页>Scan delete folder problems
Scan delete folder problems
2022-07-25 20:35:00 【Royal shadow time】
/* practice : Delete a directory with many levels of subdirectories ( recursive )
Tips : Multi level directory , You can only delete your son first , Delete Lao Tzu again
In the process of recursive scanning , Delete all files first , If it's a folder , Can only recursively enter , Scan again .
Then delete the parent directory */
public class Work4 {
public staticvoid main(String[] args) {
Filef=new File("F:\\javabase");
scanFolder(f);
}
private staticvoid scanFolder(File f) {
// Robustness judgment
if(f.isFile())
{ thrownew RuntimeException(" brother , You need to transfer the folder ");}
File[]l = f.listFiles();
for(File i : l)
{
if(i.isFile())
{
i.delete();
}
else
{
scanFolder(i);// If it's a folder , Then continue to search
// If it is a folder, send the folder as the parent directory to a scanning function , So you can go through f.delete() To delete
// i.delete();// Search done , Delete folder
}
}
f.delete();// Because each cycle is the whole cycle to the end , If you get to the bottom, you will run the current command
}
}
边栏推荐
- [today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
- Jmeter——接口测试
- Clickhouse notes 02 -- installation test clickvisual
- Cloud native guide: what is cloud native infrastructure
- Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34
- Mobile web layout method
- Vulnhub | dc: 6 | [actual combat]
- [today in history] July 18: Intel was founded; The first photo was posted on the world wide web; EBay spins off PayPal
- C language file reading and writing
- Fanoutexchange switch code tutorial
猜你喜欢

网络协议:TCP Part2
![[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance](/img/2d/c23a367c9e8e2806ffd5384de273d2.png)
[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance

毕业从事弱电3个月,我为什么会选择转行网络工程师

【高等数学】【6】多元函数微分学

【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)
![Summarize the level of intelligent manufacturing discussion [macro understanding]](/img/84/3addabdf857c562535a4085782d3e8.png)
Summarize the level of intelligent manufacturing discussion [macro understanding]

Google guava is just a brother. What is the real king of caching? (glory Collection Edition)
![[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console

MySQL 日期【加号/+】条件筛选问题

Has baozi ever played in the multi merchant system?
随机推荐
Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework
Arrow 之 Parquet
Online XML to JSON tool
Advantages of network virtualization of various manufacturers
MySQL date [plus sign / +] condition filtering problem
Network protocol: TCP part2
Working principle of radar water level gauge and precautions for installation and maintenance
[advanced mathematics] [5] definite integral and its application
Formatdatetime explanation [easy to understand]
Mobile web layout method
接口请求合并的3种技巧,性能直接爆表!
Open source SPL enhances mangodb computing
使用cookie登录百度网盘(网站使用cookie)
MySQL 日期【加号/+】条件筛选问题
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input
Step num problem
qml 结合 QSqlTableModel 动态加载数据 MVC「建议收藏」
[today in history] July 5: the mother of Google was born; Two Turing Award pioneers born on the same day
Proxy implements MySQL read / write separation
文件操作详解