aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Read this for quick help please! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Read this for quick help please!" Watch "Read this for quick help please!" New topic
Author

Read this for quick help please!

amer seif el dine
Greenhorn

Joined: Jul 26, 2001
Posts: 16
Hi Programmer,
I'm a beginner ans i'm asking how to know that two files have exactly the same content for security reasons and how to compare
them?
N.B: the two files don't have necessarly the same name or directory.
Thanks a lot .
Nura Horne
Ranch Hand

Joined: Jul 26, 2001
Posts: 40
You could set up a loop and read a char from each at a time, similar to:
(PSEUDOCODE)
areSame = true
while not end-of-file
  Char1 = read char from file1
  Char2 = read char from file2
  If not char1 = char2 then areSame = false
end while
(END PSEUDOCODE)
If we get to this point and areSame is true we know the two files are identical.
This basic algorithm could be optimised, but its best to get a basic system working first before tweaking it.
Hope this helps, A
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Read this for quick help please!