Check if file is already open

前端 未结 8 1202
悲&欢浪女
悲&欢浪女 2020-11-22 14:32

I need to write a custom batch File renamer. I\'ve got the bulk of it done except I can\'t figure out how to check if a file is already open. I\'m just using the java.

8条回答
  •  逝去的感伤
    2020-11-22 15:13

    I don't think you'll ever get a definitive solution for this, the operating system isn't necessarily going to tell you if the file is open or not.

    You might get some mileage out of java.nio.channels.FileLock, although the javadoc is loaded with caveats.

提交回复
热议问题