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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Read this for quick help please!" Watch "Read this for quick help please!" New topic

Read this for quick help please!

amer seif el dine

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
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:
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
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
I agree. Here's the link:
subject: Read this for quick help please!
Similar Threads
Comilation Problem
Comparing XML files of sizes greater than 2gb
how many root element can be defined in one dtd files
Can't compile
Two WAR files to an EAR