1import java.nio.file.Files;
2import java.nio.file.Path;
3import java.nio.file.Paths;
4public class FilesExample {
5 public static void main(String args[]) {
6 //Creating a Path object
7 Path path = Paths.get("D:\\sample.txt");
8 //Verifying if the file is readable
9 boolean bool = Files.isReadable(path);
10 if(bool) {
11 System.out.println("readable");
12 } else {
13 System.out.println("not readable");
14 }
15 bool = Files.isWritable(path);
16 if(bool) {
17 System.out.println("writable");
18 } else {
19 System.out.println("not writable");
20 }
21 bool = Files.isExecutable(path);
22 if(bool) {
23 System.out.println("executable");
24 } else {
25 System.out.println("not executable");
26 }
27 }
28}