Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to identify File Copied completely  RSS feed

 
Sanket Akre
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Can you please tell me how to identify that file is copied completely or not?

Any java API for that, any point where by we can come to know that file coping done successfully?

Thanks
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you copying the file?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what hashes like MD5 are for.
 
Sanket Akre
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file is coming from external system.

My program should read this file when is it finished copying completely.

Is there any API to identify that file copied completely.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the file is being copied by some other application and you want to know when that application has successfully copied the whole file to its destination, then the algorithm to implement is one where that other application explicitly tells your application that it has finished. Other strategies which involve just looking at the destination file are subject to failure.

For example you could have the other application create a second (empty) file after it has finished copying the file. Then your application would just wait for that second file to appear. There are other ways for the application to "send a message" but that one is easy to implement.
 
Henry Wong
author
Sheriff
Posts: 22845
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Two common techniques, that I have seen frequently done, are...

1. Upload the file with a name that will be ignored. For example, with an "ignore" extension or something like that. When the upload is complete, then rename the file.

2. Have the receiving program look at the modification times of the file, and use some sort of timeout on the file. For example, if a newly appeared file, hasn't changed its modification times in 10 minutes, then the upload can be assumed to be completed.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!