JAVA_Math_and_File

 1 import java.io.*;
 2
 3 public class FileList {
 4     public static void main (String[] args){
 5         File f = new File("d:/A");
 6         System.out.println(f.getName());
 7         tree(f,1);
 8     }
 9
10     private static void tree(File f,int level) {
11         File[] childs= f.listFiles();
12         for(int i = 0; i < childs.length; i++){
13             for(int j = 0; j < level; j++){
14                 System.out.print("    ");
15             }
16             System.out.println(childs[i].getName());
17             if(childs[i].isDirectory()){
18                 tree(childs[i],level + 1);
19             }
20         }
21
22     }
23 }
时间: 2024-08-05 23:41:33

JAVA_Math_and_File的相关文章