开发者

Delete file in java

I want to delete file on windows OS using java, how ever开发者_如何学Go 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜