Here is my case:
String dir = "C:/root/dir1/";
for(File f: new File(dir).listFiles()) {
}
On executing:
System.out.println(new File(dir).isDirectory());
System.out.println(new File(dir));
gives
false
root/dir1
The path stored in the string is valid. On converting the string to file type it looses the separator; how can the directory name be preserved?
Thank you.
To create a directory use the following code. Note the use of .mkdir() method and the double backslash.
In your code I would bet System.out.println(new File(dir).isFile() would return true.