You can do this if you want to block:
File f1 = new File(Your file path); f1.setExecutable(false); f1.setWritable(false); f1.setReadable(false);
And to unlock, you can simply do this:
File f1 = new File(Your file path); f1.setExecutable(true); f1.setWritable(true); f1.setReadable(true);
Before use
Check if file permission is allowed:
file.canExecute(); – return true, file is executable; false is not. file.canWrite(); – return true, file is writable; false is not. file.canRead(); – return true, file is readable; false is not.
For a Unix system, you must enter this code:
Runtime.getRuntime().exec("chmod 777 file");
TheLittleNaruto
source share