File.setWritable(boolean writable) has the following syntax.
public boolean setWritable(boolean writable)
In the following code shows how to use File.setWritable(boolean writable) method.
/* w w w . ja v a 2 s.co m*/ 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.