Core API
How do I determine if a pathname is a directory?
To determine if an abstract pathname is a directory we can use the File.isDirectory() method. Here is an example code. package org.kodejava.io; import java.io.File; public class IsDirectoryExample { public static void main(String[] args) { // Creates a instance of File. File file = new File("C:/Users/wsaryada"); // Check if the abstract pathname is a directory by […]
Article by Wayan · Source: Kode Java ↗
To determine if an abstract pathname is a directory we can use the File.isDirectory() method. Here is an example code.
package org.kodejava.io;
import java.io.File;
public class IsDirectoryExample {
public static void main(String[] args) {
// Creates a instance of File.
File file = new File("C:/Users/wsaryada");
// Check if the abstract pathname is a directory by calling
// isDirectory() method of the File class.
if (file.isDirectory()) {
System.out.println("This file is a directory.");
} else {
System.out.println("This is just an ordinary file.");
}
}
}
Comments 0
Share your questions, experiences, or feedback about this article.
Sign in with Google to leave a comment.
Sign in with Google
No comments yet. Be the first to share your feedback.