How to know whether a file copying is 'in progress'/complete in java (1.6) -
this question has answer here:
i writing directory monitoring utility in java(1.6) using polling @ intervals using lastmodified
long value indication of change. found when polling interval small (seconds) , copied file big change event fired before actual completion of file copying.
i know whether there way can find status of file in transit, complete etc.
environments: java 1.6; expected work on windows , linux.
there 2 approaches i've used in past platform agnostic.
1/ ftp transfers controlled put, may not directly relevant.
basically, whatever putting file file.txt
will, when it's finished, put small (probably zero-byte) dummy file called file.txt.marker
(for example).
that way, monitoring tool looks marker file appear and, when does, knows real file complete. can process real file , delete marker.
2/ unchanged duration.
have monitor program wait until file unchanged n seconds (where n reasonably guaranteed large enough file will finished).
for example, if file size hasn't changed in 60 seconds, there's chance it's finished.
there's balancing act between not thinking file finished because there's no activity on it, , wait once finished before can start processing it. less of problem local copying ftp.
Comments
Post a Comment