Test03 delete方法
import java.io.File;
import java.io.IOException;
/*
boolean delete()
删除由此抽象路径名表示的文件或目录。
*/
public class File_Test03 {
public static void main(String[] args) throws IOException {
     //在此项目下创建2个文件
File file = new File("bbbb");
File file2 = new File("dd.txt");

     file.creatNewFile();

     file2.creatNewFile();
     //删除
     boolean delete = file.delete();
        System.out.println(delete);//true
//此时a文件夹下面还有文件,因为下面还有文件是受保护的,所以不能直接删掉
File file = new File("D:\\Develop\\IntelliJ IDEA 2021.1.1\\MyTest\\a");
boolean delete = file.delete();
System.out.println(delete);//false,删除失败
//此时路径是完整的,cc.txt下面也没有别的文件了,所以可以直接删除
File file4 = new File("D:\\Develop\\IntelliJ IDEA 2021.1.1\\MyTest\\a\\cc.txt");
boolean delete4 = file4.delete();
System.out.println(delete4);//true,删除成功



}
}