import java.io.File;
public class FileTest2
{
public static int count = 0;public static void parse(File[] files)
{ if(files.length == 0)
{
FileTest2.count--;
System.out.println(); return;
} else
{ for(File f : files)
{ if(f.isDirectory())
{
FileTest2.count++; for(int i = 1; i <= FileTest2.count; i++)
{
System.out.print("\t");
}
System.out.println(f.getName()); File[] files2 = f.listFiles();
FileTest2.parse(files2);
}
} for(File f : files)
{ if(!f.isDirectory())
{ for(int i = 0; i <= FileTest2.count; i++)
{
System.out.print("\t");
}
System.out.println(f.getName());
}
}
FileTest2.count--;
}
}public static void main(String[] args)
{ File file = new File("C:\\Program Files\\Java\\jre6"); File[] files = file.listFiles();
FileTest2.parse(files);
}
}