Hi Guys I am kind of stuck now..this is what i would my program to do... I want to compare two different direcotries and compare the files in those direcotries...and write a log saying this is what missing... in my case there will be a two direcotry A and B A will have the most latest files and i will be comparing A to other direcotries to check the update... I am planning to write a servlet...so that my collegue can check things on the web as well... would you be able to help me guys... your time is much appreciated... regards, Rashmi
Joined: Jan 29, 2003
You can use a File object to get a list of files in a directory. You'll probably have a recursive routine that calls itself to deal with subdirectories. I'd build myself a structure that holds the sorted contents of one directory, maybe a TreeSet of File objects with a Comparator to get them in path plus name order. Create two of these, one for directory A and another for directory B. Then I'd build something to pull elements from these two sets with a classic sorted set comparison routine:
I'd probably put the result of each trip through this loop into a little object with a flag for A-only, B-only, Both-match, Both-date or size mismatch, and put all of those into yet another structure. Note - no Servlet stuff here yet. You could use this from a fat Java client and unittest it separately. Finally, pull that collection of result objects into your servlet or JSP page and write out the results. Any of that help?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Aug 13, 2001
Hi i must admit that this is not very clear to me...i will try my own things till i have break through... thank you for your time...i do appreciate it...