版权声明:JAVA https://blog.csdn.net/weixin_43190126/article/details/84894144
package com.qyl.file;
import java.io.File;
import org.junit.Test;
public class testFile2 {
@Test
public void testfile2() throws Exception {
File file = new File("E:/区区/胡老师/TestFile/ludashi8.2");
deletAll(file);
}
public boolean deletAll(File File) {
if (!File.exists()) {
return false;
}
if (File.isFile()) {
File.delete();
}else if (!File.delete()) {
File[] listfile = File.listFiles();
for (File file1 : listfile) {
deletAll(file1); //递归循环
}
}
return true;
}
}