Java: unmark file is read-only
java, windows
Solution
http://java.sun.com/j2se/1.6.0/docs/api/java/io/File.html#setReadOnly%28%29
File file = new File("foo.bar");
if(file.setReadOnly()) {
System.out.println("Successful");
}
else {
System.out.println("All aboard the fail train.");
}
Before Java6, you could not undo this. To get around this, they put in `File.setWritable(boolean)` which can be used as so
File file = new File("foo.bar");
if(file.setWritable(false)) {
System.out.println("Successful");
}
else {
System.out.println("All aboard the fail train.");
}
if(file.setWritable(true)) {
System.out.println("Re-enabled writing");
}
else {
System.out.println("Failed to re-enable writing on file.");
}
Problem
Can I do this on Java? I'm using windows...