Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File comparison

 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing an app that has to compare files to previous versions of that file, to see if it's changed. So far, I've read all the files, recording their 'last modified' attribute - to compare the files (as there may be a lot), I first compare this attribute. If it has changed, I need a way to see if the file has changed - I cannot hold a copy of the file to compare them directly (this would be slow anyway), I need to do some kind of checksum. Anyone know anything about this?
Thanks.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you wish to do a check sum, you could use the java.util.zip.CRC32 class. An example:

Hope this helps
[This message has been edited by Carl Trusiak (edited November 09, 2000).]
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic