我有类似于下面的代码.此代码在Windows和Linux上运行良好,但在Mac 10.5和10.6上java.io.Exception不支持opertaion.
非常感谢你在这方面的任何帮助.
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)
{
}
Run Code Online (Sandbox Code Playgroud)