简体   繁体   English

Mac OS中的Java文件锁定

[英]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. 使用java.nio软件包进行文件锁定在Windows OS上可以正常使用,但同一程序在Mac OS上不能正常使用。

I am trying to delete the locked file in Windows where its not deleting the file. 我正在尝试在Windows中删除锁定的文件,而不删除文件。 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. 但是我试图在Mac OS中实现同样的目的,即使文件被FileWriter / FileOutputStream锁定或打开,它也会删除文件。

Any suggestion for this issue ? 对这个问题有什么建议吗? Is it bug in File lock implementation ? 文件锁实现中是否存在错误?

Thanks. 谢谢。

It's not a bug (unless you call Windows a bug) 这不是错误(除非您将Windows称为错误)

Locks are advisory on *nix systems. 锁是在* nix系统咨询 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. 在Windows中,它几乎是一样的,除了系统命令检查锁和IIRC时,打开文件的默认模式是排他锁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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