Return | Method | Summary |
---|---|---|
boolean | setExecutable(boolean executable) | A convenience method to set the owner's execute permission for this abstract pathname. |
boolean | setExecutable(boolean executable, boolean ownerOnly) | Sets the owner's or everybody's execute permission for this abstract pathname. |
boolean | setReadable(boolean readable) | A convenience method to set the owner's read permission for this abstract pathname. |
boolean | setReadable(boolean readable, boolean ownerOnly) | Sets the owner's or everybody's read permission for this abstract pathname. |
boolean | setReadOnly() | Marks the file or directory named by this abstract pathname so that only read operations are allowed. |
boolean | setWritable(boolean writable) | A convenience method to set the owner's write permission for this abstract pathname. |
boolean | setWritable(boolean writable, boolean ownerOnly) | Sets the owner's or everybody's write permission for this abstract pathname. |
import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File("c:/a.htm");
file.setExecutable(true);
file.setReadable(true);
}
}
Mark file or directory Read Only
import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File("C:/data.dat");
boolean blnMarked = file.setReadOnly();
System.out.println("Was file marked read only ?: " + blnMarked);
System.out.println("Is file writable ?: " + file.canWrite());
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |