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

java.io.FileNotFoundException should return more meaningful detail strings

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.2.0
    • core-libs
    • 1.2fcs
    • x86
    • windows_nt
    • Not verified



      Name: rm29839 Date: 05/21/98


      It is very difficult to determine if a file is available for use.

      FileNotFoundException (with the same message)is generated in two cases:

      1. The file does not exist.
      2. The file exists but is locked by another user.

      The absence of the alternate message text means programmers have to elimate
      all the probable causes and then assume the improbable:

      File file = new File(fileName);
      if (file.exists()) { // whew it exists
          if (file.canWrite()) { // whew I'm allowed
             try {
                DataOutputStream = new ...... new FileOutputStream(file);
             catch (FileNotFoundException e) { // I guess not - perhaps someone is using it.
      ...
      Every programmer has to go through these contortions to generate an accurate message
      to the program user.

      Also note that java.io.File could use an isAvailableRead/Write() function (or similar).
      (Review ID: 29111)
      ======================================================================

            mr Mark Reinhold
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: