本帖最后由 tshch1989 于 2013-3-29 22:05 编辑
import java.io.*;
class Demo
{
public static void main(String[] args)
{
File fl=new File("d:\\s");
//System.out.println(fl.isDirectory());
listD(fl,0);
}
public static void listD(File f,int i){
File[] ff=f.listFiles();
for (File fs:ff){
for(int x=0;x<i;x++)
System.out.print(" ");
if(fs.isDirectory()){
System.out.println("++"+fs.getName());
listD(fs,++i);}
else{
System.out.println("--"+fs.getName());
}
}
}
}
记事本写的,格式不怎么好,请大家谅解;
|
|