JDK-4040846 : java.io.File.mkdirs return false if directory name ends with a "/"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 1997-03-24
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Duplicate :  
Relates :  
Description
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());

        }
}

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

WORK AROUND Don't put any separator character at the end of directory name.
11-06-2004

EVALUATION Fixed by the general rewrite of java.io.File in JDK 1.2beta4 (4131169). -- mr@eng 6/19/1998
19-06-1998