s-day08--File里面的删除方法
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
package com.inmind.file01;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/*
|
||||||
|
public boolean delete() :删除由此File表示的文件或目录。
|
||||||
|
|
||||||
|
注意:
|
||||||
|
1.如果一个文件夹中还有子内容,这个文件夹不允许直接删除,先删除所有子内容,才能删除父文件夹
|
||||||
|
2.删除方法是物理删除,不能恢复
|
||||||
|
*/
|
||||||
|
public class Demo06 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
File file = new File("c\\c.txt");
|
||||||
|
|
||||||
|
System.out.println(file.delete());
|
||||||
|
File file1 = new File("c");
|
||||||
|
System.out.println(file1.delete());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user