Java source code examples

Java source code samples. Java code examples.

Checks whether a file or directory has executable permission or not.

* * * * * 1 votes

Checks whether a file or directory has executable permission or not.

The canExecute method of File class can be used for finding out whether the given file has executable permission or not.

import java.io.File;
/**
 * File class examples.
 *
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp");

		// Check whether the file has executable permission or not.
		boolean value = file.canExecute();

		System.out.println("File executable permission status : "+value);
	}
}

Tags: java.io

Discuss This Code