I'd like to use isDirectory()
method (java.io.File class). I created a simple test code to try out this method, however I always get a 'cannot find symbol' error.
My code:
import java.io.File;
public class MyUtils {
public static void main(String[] args) {
String path = "/this/is/not/a/valid/path";
boolean ValidPath = path.isDirectory();
System.out.println(ValidPath);
}
}
Because your path
is a String
object. You may instantiate a File
object with the path String
:
boolean ValidPath = new File(path).isDirectory();