当前位置:网站首页>Case - traversing the directory (file class & recursive call)
Case - traversing the directory (file class & recursive call)
2022-06-13 05:05:00 【Jason_ LH1024】

package it.com;
import java.io.File;
public class DiGuiDemo03 {
public static void main(String[] args) {
// Create a... Based on the given path File object
File srcFile = new File("E:\\itcast");
// Calling method
getAllFilePath(srcFile);
}
// Define a method , Used to get all the contents in a given directory , Parameters are created in the first step File object
public static void getAllFilePath(File srcFile){
// Get the given File Of all files or directories in the directory File Array
File[] fileArray = srcFile.listFiles();
// Traversing this File Array , Get every one File object
if(fileArray !=null){
for (File file:fileArray) {
// Judge that File Is the object a directory
if (file.isDirectory()){
// yes , Then recursively call
getAllFilePath(file);
}else {
// No , Get the absolute path output on the console
System.out.println(file.getAbsolutePath());
}
}
}
}
}

边栏推荐
- Nonstandard compiler attribute extension
- 关于匿名内部类
- Bm1z002fj-evk-001 startup evaluation
- Metartc4.0 integrated ffmpeg compilation
- Embedded hardware: electronic components (1) resistance capacitance inductance
- Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution論文淺析
- Chapter 18 pagination: Introduction
- Std:: Map empty example
- Implementing the driver registration initcall mechanism on stm32
- Gradient descent, learning rate
猜你喜欢

C language learning log 12.14

Section 3 - functions

Ruoyi cloud startup tutorial (hand-held graphics)

Time display of the 12th Blue Bridge Cup

Regular expressions in QT

Kaggle 时间序列教程

List collection concurrent modification exception

Mysql8.0.13 installation tutorial (with pictures)

Stepping on a horse (one stroke)

Dup2 use
随机推荐
Section 3 - functions
C language learning log 1.22
Dup2 use
Mysql8.0.13 installation tutorial (with pictures)
语音信号分帧的理解
[reprint] complete collection of C language memory and character operation functions
Interpretation of QT keypressevent
Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution論文淺析
QT direction key to move focus
2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation
Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution论文浅析
Chapter 18 pagination: Introduction
RMQ、LCA
C language exercise 1
Article 29: assuming that the mobile operation does not exist, is expensive, and is not used
Violence enumeration~
Search DFS and BFS
Bomb disposal cat
Force deduction 121 questions
lookup