commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JavaDev7 <user100...@post.sk>
Subject Re: [io] FileMonitor. How to deal with a huge file whom copy is longer than file monitor checkAndNotify call frequency
Date Wed, 27 Apr 2011 07:48:24 GMT
Hi,

on windows, it is simple to detect if file was copied or is copying..
You should start thread and check if you can obtain lock on file if not 
you sleep on some period and then try again..

Try:
FileChannel fileChannel = file.getChannel();
 fileLock = fileChannel.tryLock();
            if (fileLock != null){
                System.out.println("File is locked");
                accessTheLockedFile();
            }

Here is link with sample code:
http://www.javabeat.net/tips/37-locking-files-using-java.html

The problem is on linux where you can obtain lock on copying file..
We solved this problem by renaming file with correct extension after copying
was complete...

--
View this message in context: http://apache-commons.680414.n4.nabble.com/io-FileMonitor-How-to-deal-with-a-huge-file-whom-copy-is-longer-than-file-monitor-checkAndNotify-caly-tp3477448p3477469.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message