Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Compare files  RSS feed

 
pranav pranav
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do any one of you know a freeware written in java,or a sample code, or package that needs to be used,to compare two folders on the same machine and list the files that are different and that are same.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

This is relatively easy and entertaining to write for yourself. Have you worked with the File object APIs? If you create a File with the name of a directory you can ask it for a list of files in the directory. When one of those turns out to be another directory use recursion to drill into that one, too. Give a holler if that sounds complicated.

You could put the names of the files you find into an ordered List or Set. With two ordered lists you can use this (ancient) logic:

I did this in Pascal many years ago with 14 options of what to do with files.

I still use it to synchronize directories.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to address freeware ... if you really just want somehting to use in a hurry, WinDiff is not bad - google for downloads. I use something called SynchronizeIt! and CompareIt! that work, but the UI is a bit funny. And I really ought to register it. Both of these let you compare file contents, which I didn't even mention above. Cheers!
[ March 28, 2005: Message edited by: Stan James ]
 
pranav pranav
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info...
I dont know if you got the question right...

I need to compare the contents of the each file with same name in both the folders and say if the file is different from one another or same
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple text file compare routine if you want to write your own, but something like WinDiff is a lot smarter. CompareIt lets you move lines back and forth between the two files you're comparing for a nice manual merge. I don't know anything that would attempt to compare binaries like Word docs.
 
pranav pranav
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks again...
I dont need a windows tool
I am trying use this... to find if the file has changed
http://www.bmsi.com/java/#diff

Progress is this....
There is a thread that generates htmls ...
if(newly generated file exits in production)
{
if(is this file changed)
move to production
else
dont move as it has not changed


}
else
{
move it to production
}

//Move all the changed files
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!