Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Java's file-manipulation methods often indicate failure with a return value rather than by instead of throwing an exception. The Java Tutorials for Java 7 notesnote:

Prior to the Java SE 7 release, the java.io.File class was the mechanism used for file I/O, but it had several drawbacks.

One of these drawbacks is that:

Many methods did not didn't throw exceptions when they failed, so it was impossible to obtain a useful error message. For example, if a file deletion failed, the program would receive a "delete fail" but would not know whether wouldn't know if it was because the file was missingdidn't exist, the user lacked sufficient permissions to access the filedidn't have permissions, or there was some other problem.

...

This compliant solution uses the java.nio.file.Files.delete() method from Java SE 7 to delete the file.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8707e81b6bf0324d-acd7fa57-4c13443d-96a199f8-7b2423849679337465a02e01"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

File.delete()

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5ffdb3c362239e88-2079b946-4aca462d-a7529182-9d49624c23b4ecd9f6eaabb3"><ac:plain-text-body><![CDATA[

[[J2SE 2011

AA. Bibliography#J2SE 11]]

Files.delete()

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4a06c4ba491752ce-617b2b94-4495484e-839fbd83-6a686de47fcb86cb418fae77"><ac:plain-text-body><![CDATA[

[[Seacord 2005

AA. Bibliography#Seacord 05]]

Chapter 7, File I/O

]]></ac:plain-text-body></ac:structured-macro>

...