package test;
import java.io.File;
public class PrintFiles {
public static void main(String[] args){
File f = new File("e:/javacode/6");
printFiles(f,0);
}
public static void printFiles(File file,int level){
for(int i=0;i<level;i++){
System.out.print("-");
}
System.out.println(file.getName());
if(file.isDirectory()){
File [] f1 = file.listFiles();
for(int j =0;j<f1.length;j++){
File a = f1[j];
printFiles(a,level+1);
}
}
/*
if(file.isDirectory()){
File [] f1 = file.listFiles();
for(File j : f1){
printFiles(j,level+1);
}
}
*/
}
}
import java.io.File;
public class PrintFiles {
public static void main(String[] args){
File f = new File("e:/javacode/6");
printFiles(f,0);
}
public static void printFiles(File file,int level){
for(int i=0;i<level;i++){
System.out.print("-");
}
System.out.println(file.getName());
if(file.isDirectory()){
File [] f1 = file.listFiles();
for(int j =0;j<f1.length;j++){
File a = f1[j];
printFiles(a,level+1);
}
}
/*
if(file.isDirectory()){
File [] f1 = file.listFiles();
for(File j : f1){
printFiles(j,level+1);
}
}
*/
}
}