当前位置:网站首页>Recursively traverse directory structure and tree presentation
Recursively traverse directory structure and tree presentation
2022-06-26 05:15:00 【Light ink CGZ】
code snippet , Note the code example address . Is custom .
import java.io.File;
public class TestFile6 {
public static void main(String[] args) {
File f = new File("d:/ The movie ");
printFile(f, 0);
}
/** * Print file information * @param file File name * @param level Number of layers ( The actual is : The number of recursive calls ) */
static void printFile(File file, int level) {
// Number of output layers
for (int i = 0; i < level; i++) {
System.out.print("-");
}
// Output file name
System.out.println(file.getName());
// If file Is a directory , Then get the sub file list , And do the same operation for each sub file
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File temp : files) {
// Call the method recursively : Pay attention to wait +1
printFile(temp, level + 1);
}
}
}
}
边栏推荐
- Generalized linear model (logistic regression, Poisson regression)
- thread priority
- Baidu API map is not displayed in the middle, but in the upper left corner. What's the matter? Resolved!
- 2021年OWASP-TOP10
- [greedy college] Figure neural network advanced training camp
- The localstorage browser stores locally to limit the number of forms submitted when tourists do not log in.
- uni-app吸顶固定样式
- Use to_ Numeric to numeric type
- Image translation /gan:unsupervised image-to-image translation with self attention networks
- Zuul 實現動態路由
猜你喜欢
The localstorage browser stores locally to limit the number of forms submitted when tourists do not log in.
Why does the mobile IM based on TCP still need to keep the heartbeat alive?
The beautiful scenery is natural, and the wonderful pen is obtained by chance -- how is the "wonderful pen" refined?
百度API地图的标注不是居中显示,而是显示在左上角是怎么回事?已解决!
PHP 2D / multidimensional arrays are sorted in ascending and descending order according to the specified key values
Serious hazard warning! Log4j execution vulnerability is exposed!
[unity3d] human computer interaction input
Codeforces Round #802 (Div. 2)(A-D)
【上采样方式-OpenCV插值】
cartographer_local_trajectory_builder_2d
随机推荐
cartographer_local_trajectory_builder_2d
Zuul implements dynamic routing
Beidou navigation technology and industrial application of "chasing dreams in space and feeling for Beidou"
【Unity3D】刚体组件Rigidbody
程序人生
Mongodb image configuration method
PHP二维/多维数组按照指定的键值来进行升序和降序
C# 39. Conversion between string type and byte[] type (actual measurement)
Day3 data type and Operator jobs
[quartz] read configuration from database to realize dynamic timing task
What is UWB in ultra-high precision positioning system
PHP one sentence Trojan horse
The first gift of the project, the flying oar contract!
Yunqi lab recommends experience scenarios this week, free cloud learning
Ad tutorial series | 4 - creating an integration library file
Codeforces Round #800 (Div. 2)
Computer Vision Tools Chain
cartographer_optimization_problem_2d
localStorage浏览器本地储存,解决游客不登录的情况下限制提交表单次数。
《财富自由之路》读书之一点体会