How can I lock a file using java (if possible)

前端 未结 8 1181
无人及你
无人及你 2020-11-21 23:48

I have a Java process that opens a file using a FileReader. How can I prevent another (Java) process from opening this file, or at least notify that second process that the

8条回答
  •  醉话见心
    2020-11-22 00:39

    use java.nio.channels.FileLock in conjunction with java.nio.channels.FileChannel

提交回复
热议问题