当前位置:网站首页>递归遍历目录结构和树状展现
递归遍历目录结构和树状展现
2022-06-26 05:05:00 【浅墨cgz】
代码片段,注意代码示例地址。是自定义的。
import java.io.File;
public class TestFile6 {
public static void main(String[] args) {
File f = new File("d:/电影");
printFile(f, 0);
}
/** * 打印文件信息 * @param file 文件名称 * @param level 层次数(实际就是:第几次递归调用) */
static void printFile(File file, int level) {
//输出层次数
for (int i = 0; i < level; i++) {
System.out.print("-");
}
//输出文件名
System.out.println(file.getName());
//如果file是目录,则获取子文件列表,并对每个子文件进行相同的操作
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File temp : files) {
//递归调用该方法:注意等+1
printFile(temp, level + 1);
}
}
}
}


边栏推荐
- localStorage浏览器本地储存,解决游客不登录的情况下限制提交表单次数。
- 【Unity3D】人机交互Input
- Introduction to classification data cotegory and properties and methods of common APIs
- Method of saving pictures in wechat applet
- PowerShell runtime system IO exceptions
- torchvision_transform(图像增强)
- 2022.2.11
- torchvision_ Transform (image enhancement)
- Interpretation of yolov5 training results
- Multipass Chinese document - share data with instances
猜你喜欢

UWB ultra high precision positioning system architecture

How MySQL deletes all redundant duplicate data
![[unity3d] collider assembly](/img/de/29ecf4612c540e2df715f56c31cf1a.png)
[unity3d] collider assembly

Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing

A company crawling out of its grave

为什么许多shopify独立站卖家都在用聊天机器人?一分钟读懂行业秘密!

5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)

Using requests library and re library to crawl web pages

Image translation /gan:unsupervised image-to-image translation with self attention networks

Second day of deep learning and tensorfow
随机推荐
Introduction to classification data cotegory and properties and methods of common APIs
Codeforces Round #800 (Div. 2)
Sentimentin tensorflow_ analysis_ cell
YOLOv5-6.0的一些参数设置和特征图可视化
22.2.8
Selection of programming language
RESNET practice in tensorflow
Collections and dictionaries
-Discrete Mathematics - Analysis of final exercises
Computer Vision Tools Chain
Method of saving pictures in wechat applet
Zuul 實現動態路由
5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)
Windows下安装Tp6.0框架,图文。Thinkphp6.0安装教程
LSTM in tensorflow_ Layers actual combat
A method of quickly transplanting library function code to register code by single chip microcomputer
Statsmodels Library -- linear regression model
5. <tag-栈和常规问题>补充: lt.946. 验证栈序列(同剑指 Offer 31. 栈的压入、弹出序列)
2022.2.17
2022.2.10