Does Java FileChannel.tryLock work on Mac OS X?

I have a code similar to below. This code works fine on Windows and Linux, but on Mac 10.5 and 10.6 gives java.io.Exceptionopertaion is not supported.

Thanks so much 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)
{
}
+5
source share
1 answer

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

Apple has not implemented file blocking on multiple selected file systems.

... and the link post was published in May 2005.

+3
source

All Articles