api 文档中是这么写的
--------------------------------------
Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.
Note that the Files class defines the delete method to throw an IOException when a file cannot be deleted. This is useful for error reporting and to diagnose why a file cannot be deleted.
--------------------------------------
大致意思是,如果这个File类代表的是一个目录,那么会这个目录中不能有文件,调用这个方法以后,将不再有这个目录。如果有文件将返回false;如果这个file类是一个文件的话,这时候如果文件的权限是可读可写的,将返回true,如果不是的话,会抛出异常。可以做个测试看看,多动手
|