I'm using Windows-7 with java 7 update 6 and found this weird (at least to me) behavior -
I have two files E:\delete1.txt and E:\delete2.txt both are read only files, when I try to delete file like following it gets deleted without any issues -

File file = new File("E:\\delete1.txt"); 
assertTrue(file.delete());

But when I delete file using nio API like following -

Path path = Paths.get("E:\\delete2.txt");
Files.delete(path);

It throws java.nio.file.AccessDeniedException.

Why different behavior for same operation with old and new nio API?

Edit
Report