File class canExecute()method example
Tests whether the application can execute the file
File class canExecute()method example. This example shows you how to use canExecute()method.This method Tests whether the application can execute the file denoted by this abstract pathname
Here is the code:-
/**
* @Program that Tests whether the application can execute the file denoted by
this abstract pathname
* CanExecute.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
public class CanExecute {
public static void main(String[] args) {
// Create a File object
File myFile = new File("/home/girish/Desktop/Document.txt");
//Tests whether the application can execute the file
if (myFile.canExecute()) {
System.out.println(myFile.getAbsolutePath() + "Can Execute: ");
} else {
System.out.println(myFile.getAbsolutePath() + " Cannot Execute: ");
}
}
} |
Output of the program:-
| /home/girish/Desktop/Document.txt Can Execute: |
|