convert a string to a directory name
Here is my case:

    String dir = "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.
convert a string to a directory name
===

Here is my case:

    String dir = "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.