Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4952996

File.delete() should throw IOException instead of returning false

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      Name: rmT116609 Date: 11/12/2003


      A DESCRIPTION OF THE REQUEST :
      if java.io.File.delete() fails, the result value is false. there is no further information about the reason why it failed. it would be better that this method would throw a IOException with the reason why it failed. (in my case, it failed because another process still had a reference to the file.)

      JUSTIFICATION :
      with the current behaviour (just return false if delete() failed) there is no information why the deletion failed.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      e.g. if the file can't be deleted because it's still in access by another process, don't just return false but throw an IOException with the reason (e.g. "File is still referenced by another process.")
      ACTUAL -
      the method just returns false.

      ---------- BEGIN SOURCE ----------
      File file = new File("readme.txt");
      boolean result = file.delete();
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      you have to guess the reason why delete() failed.
      (Incident Review ID: 225294)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: