Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

992458Feb 26 2013 — edited Feb 26 2013
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2013
Added on Feb 26 2013
1 comment
352 views