Change to executable, readable, writable
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());
}
}
Home
Java Book
File Stream
Java Book
File Stream
File:
- File
- Constants from File class
- Create file object
- Is it executable, readable or writable
- Compare two file path
- Create a file
- Delete a file
- Is it a file or a directory
- Whether the file or directory denoted by this abstract pathname exists
- Whether this abstract pathname is absolute
- Is this file hidden
- Get the file last modified time
- Get the file size
- Get file path and name
- Get free space, total space, usable space
- Get parent file
- Return file in a directory
- The file system roots
- Create new directories
- Rename file
- Change to executable, readable, writable
- Change last-modified time
- Get string representation of a file location
- Convert file location to URI and URL