java获取文件夹下所有文件的名称

 java获取文件夹下所有文件的名称

 1 import java.io.File;
 2 
 3 public class GetFoldFileNames {
 4 
 5     /**
 6      * 
 7      * @author zdz8207
 8      */
 9     public static void main(String[] args) {
10         getFileName();
11     }
12 
13     public static void getFileName() {
14         String path = "G:/lxz/20130611"; // 路径
15         File f = new File(path);
16         if (!f.exists()) {
17             System.out.println(path + " not exists");
18             return;
19         }
20 
21         File fa[] = f.listFiles();
22         for (int i = 0; i < fa.length; i++) {
23             File fs = fa[i];
24             if (fs.isDirectory()) {
25                 System.out.println(fs.getName() + " [目录]");
26             } else {
27                 System.out.println(fs.getName());
28             }
29         }
30     }
31 }
大自然,飘然的风,QQ群: python技术交流群:453879716,人工智能深度学习群:251088643
golang技术交流群:316397059,vuejs技术交流群:458915921 渗透技术:534096581,囤币一族:621258209,有兴趣的可以加入
微信公众号:大自然预测(ssqyuce)原双色球预测, 心禅道(xinchandao)
原文地址:https://www.cnblogs.com/zdz8207/p/3132356.html