import java.io.*;
class DeleteDirectory
{
public static void main(String[] args)
{
File f2=new File("d://xianjian1");
delete1(f2);
}
public static void delete1(File f2)
{
File[] arr=f2.listFiles();
for (int x=0; x<arr.length; x++)
{
if (arr[x].isDirectory())
{
delete1(arr[x]);//利用递归删除子目录
}
else
System.out.println(arr[x].toString()+".,,....:"+arr[x].delete());
}
System.out.println("dir"+f2.delete());
}
}
|
|