import java.io.File;
import java.util.Scanner;
public class FileTree {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入文件路径:");
Scanner scan=new Scanner(System.in);
File f=new File(scan.next());
if(f.isDirectory()||f.isFile()){
printFile(f,0);
}else{
System.out.println("文件路径不存在");
}
}
public static void printFile(File file,int level){
for(int i=0;i<level;i++){
System.out.print("--");
}
System.out.println(file.getName());
if(file.isDirectory()){
File []files=file.listFiles();
for(File temp:files){
printFile(temp,level+1);
}
}
}
}