In windows there is a known bug where a folder can have read only property enable.
I have a file that have this property enabled and I need to delete it. But File.delete delete this folder whereas Files.delete can't.
Here a sample to reproduce my issue. I am in the case where the folder i want to delete is empty
public static void main(String[] args) throws IOException {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File someDir = new File(tmpDir, "someDir");
Files.setAttribute(someDir.toPath(), "dos:readonly", true);
// someDir.delete(); //ok
Files.delete(someDir.toPath()); //fail
}
Files.delete seems more appropriated according to this post but in my case it doesn't work.
In this case I can set the property back to false and I am fine but what is the right choice to do between those two method ? Should I try to use both if one failed ?