In my 64-bit Windows 7 field using NTFS and Java 7 (Oracle JDK) the only thing that worked reliably for me was
boolean canDelete = file.renameTo(file)
This is surprisingly simple and also works for folders that have an โopenโ or โlockedโ file โsomewhere belowโ.
Other things I've tried and created false positives: aquire FileLock, File # canWrite, File # setLastModified ("touch"), file.getParent (). canWrite ()
source share