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

mkdir returns false if directory already exists, so mkdirs has strange behavior

XMLWordPrintable

    • sparc
    • solaris_1

      In class java.io.File, the mikdir method seems to return false if
      the directory in questions already exists. This has two bad
      properties:

      (1) It is actually difficult to tell, after a call to mkdir, whether the
      directory exists, which is usually of greater interest than whether
      the transition from nonexistent to existent occurred.

      (2) As evidence of this, the value returned by mkdirs is almost
      useless. You actually expect one of the parent directories to exist;
      so mkdirs almost always returns false. If mkdir were to return true
      iff the directory exists after the call to mkdir, then mkdirs would return
      true iff the directory (and all its parents) exist after the call to mkdirs.

            tlindholsunw Timothy Lindholm (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: