Java File.setWritable(boolean writable)
Syntax
File.setWritable(boolean writable) has the following syntax.
public boolean setWritable(boolean writable)
Example
In the following code shows how to use File.setWritable(boolean writable) method.
//from w w w . ja v a 2 s .com
import java.io.File;
public class Main {
public static void main(String[] args) {
File f = new File("C:/test.txt");
boolean bool = f.setWritable(true);
System.out.println("setWritable() succeeded?: " + bool);
bool = f.canWrite();
System.out.print("Is file writable?: " + bool);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »