This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read this for quick help please!
 
Similar Threads
Two WAR files to an EAR
Can't compile
Comilation Problem
Comparing XML files of sizes greater than 2gb
how many root element can be defined in one dtd files