File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes File Update Detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "File Update Detection" Watch "File Update Detection" New topic

File Update Detection

Persio Berberian

Joined: Aug 27, 2011
Posts: 9
I have a program that try to detect any of its files updates(Datas), because some updates are necessary to make the program work correctly, well for long time I've been comparing the last change of File in my FTP With the user File in his System.
Well but that way is kindly complicated, because if FTP Update for some reason, all files are going to be updated for the user(Also some users experienced problems, like not finding updates), then I decided to make a new system and started with a file checksums comparator, well it take (UserFile CheckSum, then take URL File Checksum) and compare each other, well it works but the problem is that I have to compare the same amount of bytes, and to make 100% sure that the file is the same I have to compare the whole file, and to compare the Whole File from URL Take too much time to do in each program startup, and without some updates the program may crash so those are important.

So... I'm here to ask you a suggestion on how I Could make a decent file updater
I'm trying to avoid store each file version in files or something like that...
Thanks =D

Edit: What I was thinking, is write all files CheckSum in a file, then user when startup program and check file and read all checksums and compare them ^^ The bad thing of that is... That on every update I gotta create a new list of CheckSums ^^
Or I could make it connect to a server that will send the list of checksums ^^ but that's a bit annoying ;/
Rob Spoor

Joined: Oct 27, 2005
Posts: 20193

If you're using Java 7 you can use java.nio.file.WatchService for this.

How To Ask Questions How To Answer Questions
Persio Berberian

Joined: Aug 27, 2011
Posts: 9
Well but this WatchService is a listener for local files, I need a listener for files in my FTP, because client is supposed to download updated files ^^
Paul Clapham

Joined: Oct 14, 2005
Posts: 19869

Doesn't your FTP client software give you a way to find the last changed date of a file on the server? Using that date would be easier than using a checksum.
Persio Berberian

Joined: Aug 27, 2011
Posts: 9
As I said that's what I'm doing for loong time, checking last file changed date, but that way is not good.
Oh well then you agree with me about make an Update Server :p
As I said, I don't like the "last changed" way to make those updates, if I make an update server I can compare by checksum as the server will send checksums instead of client read them from file itself :p
PS: Still searching for more suggestions :p
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45346
Too difficult for “beginning”. Moving thread.
Persio Berberian

Joined: Aug 27, 2011
Posts: 9
Thanks, maybe I'll get more opinions, by the way I already created my Update Server, when client login it open connection to update server then send a packet asking for all file checksum, then server parse packet and send the checksum that are stored in a list that refresh every 20 seconds, then client compare each checksum received that come with filename, with local computer files, if there are any file with different checksum the client will send another packet requesting the download of file that's different :p, then server will parse this packet and send file to client :p What about?

But I'm crazy for more suggestions, because Idk... what if update server become off-line I need an optional way :p
I agree. Here's the link:
subject: File Update Detection
It's not a secret anymore!