A program in Java to check if a file or directory has read and write permission or not.
In the Java program to check if a file or directory has read and write permission or not, we need to import java.io.file library first which contains all the built-in functions than can check the rights to access of a file. Sample Output: /Desktop/sample.txt cannot write. /Desktop/sample.txt cannot read.