Java Tutorial, Java Study, Learn Java, Java Lab@home, Java Cycle test, Java Projects, Java Assignments, Java Notes and much more..
import java.io.File;
class SetReadOnly
{
public static void main(String args[])
{
// Create File object
File f=new File("SetReadOnly.java");
// Mark this file read only
f.setReadOnly();
// Alternate method
// f.setReadable(true);
// Set Read only for owner only (2nd argument). If true, read only sets to owner only and not for other users if false read only for all users
// f.setReadable(true,true);
// Check whether it is read-only
System.out.println("Is this file read only (T/F)? "+f.canRead());
}
}
Is this file read only (T/F)? true
No comments:
Post a Comment