...
Wiki Markup |
---|
This compliant solution uses the {{Files.delete()}} method from Java 1.7 to delete the file. \[[J2SE 2011|AA. Bibliography#J2SE 11]\] defines {{Files.delete()}} to throw the following exceptions: |
Exception | Reason |
---|---|
|
...
if the file does not exist |
...
|
...
if the file is a directory and could not otherwise be deleted because the directory is not empty |
...
|
...
if an I/O error occurs | |
|
...
In the case of the default provider, and a security manager is installed, the SecurityManager.checkDelete(String) method is invoked to check delete access to the file |
Code Block | ||
---|---|---|
| ||
Path file = new File("file").toPath(); try { Files.delete(file); } catch (IOException x) { // handle error } |
...