package base;
import java.io.File;
public class delete {
public static void main(String[] args) {
deleteFileAndFoder("../yang");
}
static void deleteFileAndFoder(String path){
File f=new File(path);
if(f.isDirectory()){//假设是文件夹。先递归删除
String[] list=f.list();
for(int i=0;i<list.length;i++){
deleteFileAndFoder(path+"//"+list[i]);//先删除文件夹下的文件
}
}
f.delete();
}
}
import java.io.File;
public class delete {
public static void main(String[] args) {
deleteFileAndFoder("../yang");
}
static void deleteFileAndFoder(String path){
File f=new File(path);
if(f.isDirectory()){//假设是文件夹。先递归删除
String[] list=f.list();
for(int i=0;i<list.length;i++){
deleteFileAndFoder(path+"//"+list[i]);//先删除文件夹下的文件
}
}
f.delete();
}
}