This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes File comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File comparison" Watch "File comparison" New topic

File comparison

Grant Crofton
Ranch Hand

Joined: Nov 08, 2000
Posts: 154
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?
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
If you wish to do a check sum, you could use the class. An example:

Hope this helps
[This message has been edited by Carl Trusiak (edited November 09, 2000).]

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Grant Crofton
Ranch Hand

Joined: Nov 08, 2000
Posts: 154
Excellent, thanks.
Have you checked out Aspose?
subject: File comparison
It's not a secret anymore!