import java.io.*;
import java.io.File;
import java.io.IOException;
class DeleteAll{
public void DelAll(File f) throws IOException{
if (!f.exists())
System.out.println("指定的目录不存在:"+f.getName());
boolean rslt=true;
if(!(rslt=f.delete())){
File subs[]=f.listFiles();
for(int i=0;i<subs.length;i++)
{
if(subs[i].isDirectory())
DelAll(subs[i]);
rslt=subs[i].delete();
}
rslt=f.delete();
}
if(!rslt)
System.out.println("无法删除:"+f.getName());
}
}
public class Test4{
public static void main(String[] args) {
DeleteAll all=new DeleteAll();
da.delAll(new File("d:\\java"));
}
}
为啥编绎通不过呢?