file canExecute Example
file class canExecute example. This example shows you how to use canExecute method.
File class canExecute example. method generates boolean results after checking the file or directory to be runnable denoted by by the specified abstract pathname.path is abstract as it is defined inside the system.method is being called by a File class object.
Here is the code:-
/**
* @Program tests files and directories to be runnable or not
* and give results in booleans values.
* CanExecute.java
* Author:-RoseIndia Team
* Date:-30-june-2008
*/
import java.io.*;
public class CanExecute {
public static void main(String args[]) {
File data = new File("/home/mahendra/Desktop/Titanic.wmv");
data.setExecutable(true);
boolean permit = data.canExecute();
System.out.println("Existence check operation result: " + permit);
data.setExecutable(false);
permit = data.canExecute();
System.out.println("Existence check operation result: " + permit);
}
} |
Output of the program:-
Existence check operation result: true
Existence check operation result: false |
|