Mark file or directory Read Only in Java
Description
The following code shows how to mark file or directory Read Only.
Example
//w w w .ja v a 2 s.co m
import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File("C:/demo.txt");
System.out.println(file.setReadOnly());
System.out.println(file.canWrite());
}
}
The code above generates the following result.