This discussion is archived
1 Reply Latest reply: Feb 26, 2013 10:32 AM by 949137 RSS

FileLock is not working in Mac OS  - Used in Javafx application

992458 Newbie
Currently Being Moderated
In my application, there is pause & resume functionality on the file download.
To achieve this, we used java.nio.channels.FileLock to lock the file.
It is working fine in Windows, not in Macintosh OS 10.8.
We are using JRE 1.7 u 15 to run the application.
Here is the code I am using to lock a file which is working fine in Windows, but not in Macintosh

FileOutputStream file = null;

FileChannel dbFc = null;
FileLock dbFl = null;

file = new FileOutputStream( new File(sFilePath));
dbFc = file.getChannel();
dbFl = dbFc.lock();

file.write(buffer,0,read);

When I am applying lock on the FileChannel, it is not able to lock on Mac OS systems.

Is there any alternate I can use instead of FileLock .
All this logic is part of JavaFx application which will run from user's machine

Please suggest

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points