import java.io.File;
publicclass Main {
publicstaticvoid main(String[] args) throws Exception {
File file = newFile("Writable.txt");
file.createNewFile();
file.setReadOnly();
if (file.canWrite()) {
System.out.println("File is writable!");
} else {
System.out.println("File is in read only mode!");
}
file.setWritable(true);
if (file.canWrite()) {
System.out.println("File is writable!");
} else {
System.out.println("File is in read only mode!");
}
}
}