1

I work with the Java FileSystem and i will know is the File a Directory, but i get every time a NullPointerException.

Path path = Paths.get("C:/dev");
System.out.println(Files.isDirecory(path, null);
TheRadianer
  • 57
  • 1
  • 7
  • 1
    I hope you do "System.out.println(Files.isDirectory(path, null));" instead of "System.out.println(Files.isDirecory(path, null);" – Markus Apr 19 '17 at 06:50

2 Answers2

1

It is enough :

System.out.println(Files.isDirectory(path));

The second argument is an optional vargs indicating how symbolic links are handled.
Providing it null and getting a NullPointerException seems related.

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • Yea, ok thanks. I have not seen that goes also. But its interesting that if i get a Path from FileSystem `FileSystem.getRootDirectories()` its work. – TheRadianer Apr 19 '17 at 07:21
-1

You have spell error in your code. Here it is :

public static void main(String[] args) {
        Path path = Paths.get("C:/dev");
        System.out.println(Files.isDirectory(path, null);
    }

You spell wrong isDirectory

Jay Smith
  • 2,331
  • 3
  • 16
  • 27
  • I am sure it is a typo, otherwise it would not compile and give a runtime exception. Also you are missing a closing bracket – Scary Wombat Apr 19 '17 at 06:56