Reputation: 12054
I want to delete file on windows OS using java, how ever some time file may be in use by external process, how can I delete forcefully or by knowing which process use that and kill that process or any how, any code or way?
Upvotes: 2
Views: 1070
Reputation: 328546
You can call low level Windows routines via JNI (http://www.atwistedweb.com/java/jni.html) or JNA (http://jna.java.net/)
But how about a more simple solution: Download Unlocker and run it with ProcessBuilder
.
Upvotes: 3
Reputation: 29965
Java doesn't have any built-in tools to find out what process opened specific file. This is OS-specific. You must run some external tools for that, but I don't know any Windows command-line tool allowing you to do that.
Upvotes: 4