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());
}
}
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());
}
}
- duplicates
-
JDK-4040847 File.mkdirs() return false if directory name ends with a "/".
-
- Closed
-
- relates to
-
JDK-4131169 java.io.File: Respecify using abstract pathnames rather than strings
-
- Closed
-