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