isDirectory(): This method is available in the java.io.File class of Java.
Syntax:
boolean java.io.File.isDirectory()
This method tests whether the file denoted by this abstract pathname is a directory.
Parameters: NA
Returns: true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise.
Throws:
SecurityException - If a security manager exists and its java.lang.SecurityManager.checkRead(java.lang.String) method denies read access to the file
Approach
Java
import java.io.File;public class FileisDirectory {public static void main(String[] args) {String pathname = "D:\\hello.txt";File file = new File(pathname);System.out.println(file.isDirectory());}}
Output:
false
No comments:
Post a Comment