isFile(): This method is available in the java.io.File class of Java.
Syntax:
boolean java.io.File.isFile()
This method tests whether the file denoted by this abstract pathname is a normal file.
Note: A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria.
Parameters: NA
Returns: true if and only if the file denoted by this abstract pathname exists and is a normal file; 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 FileisFile {public static void main(String[] args) {String pathname = "D:\\hello.txt";File file = new File(pathname);System.out.println(file.isFile());}}
Output:
true
No comments:
Post a Comment