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

java.io.File.mkdirs return false if directory name ends with a "/"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.1
    • core-libs
    • None
    • 1.2beta4
    • sparc
    • solaris_9
    • Not verified

      I found out that although mkdirs() return false, directory did get created. It
      just give wrong return code. This is inconsistantly with the mkdir()
      method since mkdir("/a/) would create /a directory and return true.


      =========
      import java.io.*;
      import java.util.*;
      import java.util.zip.*;

      class file{
              public static void main(String[] args){
                      File f0=new File("a"+File.separator+"b"+File.separator);
                      if (!f0.mkdirs())
                              System.err.println("Can't create directory " + f0.getPath());

                      File f2=new File("c"+File.separator);
                      if (!f2.mkdir())
                              System.err.println("Can't create directory " + f2.getPath());

              }
      }

            mr Mark Reinhold
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: