从键盘接收一个文件夹路径,删除该文件夹
程序员文章站
2022-05-15 09:59:11
...
public static void main(String[] args) {
File file = new File("E:\\abc");
if (!fun3(file)) {
System.out.println("删除成功!");
}
}
/**
* 3.从键盘接收一个文件夹路径,删除该文件夹。
*/
public static boolean fun3(File file) {
File[] list = file.listFiles();
for (File f :
list) {
if (f.isDirectory()) {
fun3(f);
}
f.delete();
}
file.delete();
if (list == null) {
return true;
}
return false;
}
上一篇: CTFHub技能树RCE命令注入
下一篇: File的创建删除复制等功能实现
推荐阅读
-
php删除一个路径下的所有文件夹和文件的方法
-
键盘录入一个文件夹路径,统计该文件夹下的各种后缀名的文件的个数。例如:.txt有10个,.java有30个......
-
键盘录入一个文件夹路径,统计该文件夹(包含子文件夹)中每种类型的文件及个数,注意:用文件类型(后缀名,不包含.(点),如:"java","txt")作为key, 用个数作为value,放入到map集
-
键盘录入一个文件夹路径,统计该文件夹下的各种后缀名的文件的个数 例如:.txt有10个,.java有30个......
-
键盘录入一个文件夹路径,统计该文件夹(包含子文件夹)中每种类型的文件及个数,注意:用文件类型(后缀名,不包含.(点),如:"java","txt")作为key, 用个数作为value,放入到map集
-
5.键盘录入一个文件夹路径,统计该文件夹(包含子文件夹)中每种类型的文件及个数,注意:用文件类型(后缀名,不包含.(点),如:"java","txt")作为key,
-
键盘录入一个文件夹路径,统计该文件夹(包含子文件夹)中每种类型的文件及个数,注意:用文件类型(后缀名,不包含.(点),如:"java","txt")作为key
-
从键盘接收两个文件夹路径,把其中一个文件夹中(包含内容)拷贝到另一个文件夹中
-
从键盘接收两个文件夹路径,把其中一个文件夹中的内容拷贝到另一个文件夹中
-
1.从键盘接收两个文件夹路径,把其中一个文件夹中(包含内容)拷贝到另一个文件夹中