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 SetFileWritable
{
public static void main(String args[])
{
// Create a File object
File f=new File("SetFileWritable.java");
// It is write-able by default. So set it read-only
f.setReadOnly();
// Print whether it is write able
System.out.println("Is file writable (T/F)? "+f.canWrite());
// Make it writable.
f.setWritable(true);
// Print whether it is writable
System.out.println("Is file writable (T/F)? "+f.canWrite());
}
}
Is file writable (T/F)? false
Is file writable (T/F)? true
No comments:
Post a Comment