Reputation: 1
In windows,if you try to delete a file which has streams opened,it will return false. Where was in linux,if you try to delete a file which is open,it just deletes the file. Now i need a mechanism which works in both os to check if a file has streams opened(If the files is used by some other application)
Upvotes: 0
Views: 1206
Reputation: 2082
File lock is platform-dependent. On some platforms, the file lock is advisory, which means that unless an application checks for a file lock, it will not be prevented from accessing the file. On other platforms, the file lock is mandatory, which means that a file lock prevents any application from accessing the file.
http://www.exampledepot.com/egs/java.nio/SetFileLock.html
Upvotes: 2
Reputation: 24791
The reason is Linux uses advisory locks. Hence applications have to collaborate using locks to communicate on files.
I am not sure if its possible with pure java alone.
Upvotes: 0