• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compare files

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 listen to Steve. Just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic