file locking questions
Vince Bonfanti
vbonfanti at gmail.com
Thu Aug 27 19:30:26 PDT 2009
On Sun, Aug 23, 2009 at 12:18 PM, Alan Bateman<Alan.Bateman at sun.com> wrote:
> Vince Bonfanti wrote:
>>
>> :
>>
>> I thought I read somewhere in the JDK API docs that automatic locking
>> (or not) is file system dependent; unfortunately, I can't seem to find
>> that comment anywhere.
>>
>
> There isn't anything in the javadoc on this. You may be thinking of the
> "Platform Dependencies" section in the FileLock spec where it explains that
> the file locking API may be implemented on systems that use mandatory or
> advisory locking.
>
In case anyone's interested, I found the reference I was thinking
about, for java.io.FileOutputStream: "Some platforms, in particular,
allow a file to be opened for writing by only one FileOutputStream (or
other file-writing object) at a time. In such situations the
constructors in this class will fail if the file involved is already
open."
Further, all of the FileOutputStream constructors say this: "Throws:
FileNotFoundException - if the file exists but is a directory rather
than a regular file, does not exist but cannot be created, or cannot
be opened for any other reason."
This indicates that on some platforms a FileOutputStream constructor
might throw a FileNotFoundException if the file exists, but is opened
for writing by another thread.
More information about the nio-discuss
mailing list