开发者

Does Java FileChannel.tryLock work on Mac OS X?

I have the cod开发者_StackOverflow中文版e that similar to below. This code works fine on Windows and Linux but on Mac 10.5 and 10.6 gives java.io.Exception opertaion not supported.

Many thanks for any help in this regard.

try
{
  File file = new File("FILELOCK3");
  FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
  FileLock lock = null;
  try
  {
    lock = channel.tryLock();
  } catch (OverlappingFileLockException e)
  {
    lock.release();
    channel.close();
    System.exit(0);
  }
} catch (Exception e)
{
}


From another source I get the impression that the error depends on the underlying file system:

Apple has not implemented file locking feature on a few selected file systems.

... and the referenced message was posted in May 2005.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜