import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class PathDemo3
{
public static void main(String[] args)
{
Path filePath =
Paths.get("C:\\example\\Data.txt");
System.out.println("Path is " + filePath.toString());
try
{
//READ checks that the file exists and that the program has permission to read the file
//WRITE checks that the file exists and that the program has permission to write to the file
//EXECUTE checks that the file exists and that the program has permission to execute the file
filePath.getFileSystem().provider().checkAccess
(READ, EXECUTE);
System.out.println("File can be read and executed");
}
catch(IOException e)
{
System.out.println
("File cannot be used for this application");
}
}
}//class PathDemo3