Locked File Detection

Given the link to the File instance, is it possible (programmatically) to determine if the corresponding file is locked, and if so, which process holds the lock?

I am using Java 5 running on Windows.

Thanks Don

+4
source share
1 answer

I think that this is possible only in the hometown. You need to access FileHandle information. Write a Dll and connect it to your java application via JNI. Call NtQuerySystemInformation with SystemHandleInformation (16). You get a list with all open handles, look for FileHandles, compare FileHandles with your own file.

+2
source

All Articles