File.canWrite() give you authority to you to check file is writeable or not. See below example:

import java.io.File;

public class Writable {
public static void main(String[] args) {
File writable = new File(“path_file/test.txt”);

// set writable to false or true
writable.setWritable(true);

// returns boolean
boolean bool = writable.canWrite();

System.out.println(“Write: ” + bool);
}
}

Result: – Write: true

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.