目录递归 此程序将目录下的所有文件删除。。
你改一下就行
package untitled2;
import java.io.*; //cfan 2003/3/18 public class Untitled1 { public static void main(String[] args){
SearchDir DD = new SearchDir();
DD.SearchDirOk("C:/JBuilder7/jakarta-tomcat-4.0.3/webapps/jfrb3_18/temp") ;
}
} class SearchDir{
public SearchDir(){};
public void SearchDirOk(String Dir){
File tempFolder = new File(Dir);
System.out.println(Dir);
String fileList[] =tempFolder.list();
for (int i = 0;i < fileList.length;i++){
File tempSubFolder = new File(Dir+"/"+fileList);
if (tempSubFolder.isDirectory()){
this.SearchDirOk(Dir+"/"+fileList);
}
else {tempSubFolder.delete();}
} tempFolder.delete(); }
}
你改一下就行
package untitled2;
import java.io.*; //cfan 2003/3/18 public class Untitled1 { public static void main(String[] args){
SearchDir DD = new SearchDir();
DD.SearchDirOk("C:/JBuilder7/jakarta-tomcat-4.0.3/webapps/jfrb3_18/temp") ;
}
} class SearchDir{
public SearchDir(){};
public void SearchDirOk(String Dir){
File tempFolder = new File(Dir);
System.out.println(Dir);
String fileList[] =tempFolder.list();
for (int i = 0;i < fileList.length;i++){
File tempSubFolder = new File(Dir+"/"+fileList);
if (tempSubFolder.isDirectory()){
this.SearchDirOk(Dir+"/"+fileList);
}
else {tempSubFolder.delete();}
} tempFolder.delete(); }
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货