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

File.createNewFile() on an existing directory incorrectly throws IOException (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 1.4.2_08
    • core-libs
    • b75
    • x86
    • windows_2000
    • Verified

      Simple test case:

      public class AccessDenied {
        public static void main(String[] args) {
          try {
            java.io.File file = new java.io.File("hugo");
            boolean result = file.createNewFile();
            System.out.println(result);
          } catch (java.io.IOException ex) {
            System.out.println("Error: " + ex.getMessage());
          }
        }
      }

      When I run this on either Solaris or Windows and "hugo" does
      not exist, I get the expected output "true".

      When "hugo" exists and is a file, I get the expected output
      "false" on either platform.

      When "hugo" exists and is a directory, I get "false" on
      Solaris and an "Access is Denied" exception is thrown
      on Windows.

      This is a problem for SAP since their application depends on the
      correct behaviour, i. e. the access denied exception as unexpected
      behaviour is not acceptable since it introduces a platform
      dependency.

            jhangalsunw Jayalaxmi Hangal (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: