Files.isDirectory 空指针异常
Files.isDirectory NullPointerException
我使用 Java 文件系统,我知道文件是一个目录,但我每次都会遇到 NullPointerException。
Path path = Paths.get("C:/dev");
System.out.println(Files.isDirecory(path, null);
够了:
System.out.println(Files.isDirectory(path));
第二个参数是一个可选的 vargs,指示如何处理符号链接。
提供 null
和获得 NullPointerException
似乎是相关的。
您的代码中存在拼写错误。在这里:
public static void main(String[] args) {
Path path = Paths.get("C:/dev");
System.out.println(Files.isDirectory(path, null);
}
你拼错了isDirectory
我使用 Java 文件系统,我知道文件是一个目录,但我每次都会遇到 NullPointerException。
Path path = Paths.get("C:/dev");
System.out.println(Files.isDirecory(path, null);
够了:
System.out.println(Files.isDirectory(path));
第二个参数是一个可选的 vargs,指示如何处理符号链接。
提供 null
和获得 NullPointerException
似乎是相关的。
您的代码中存在拼写错误。在这里:
public static void main(String[] args) {
Path path = Paths.get("C:/dev");
System.out.println(Files.isDirectory(path, null);
}
你拼错了isDirectory