简体   繁体   中英

Java file lock in Mac OS

File locking using java.nio package works fine with Windows OS but same program is not working properly with Mac OS.

I am trying to delete the locked file in Windows where its not deleting the file. But same thing i am trying to achieve in Mac OS where even though file is locked or opened by FileWriter/FileOutputStream, its deleting the file.

Any suggestion for this issue ? Is it bug in File lock implementation ?

Thanks.

It's not a bug (unless you call Windows a bug)

Locks are advisory on *nix systems. Nothing prevents you from deleting a locked file except checking to see if it's locked first.

In windows it's sort of the same, except the system commands check for locks and IIRC the default mode for opening a file is with an exclusive lock.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM