aspose file tools*
The moose likes Java in General and the fly likes reporting changes (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 » Java in General
Bookmark "reporting changes (help please!)" Watch "reporting changes (help please!)" New topic
Author

reporting changes (help please!)

Rick Jones
Greenhorn

Joined: Jul 06, 2005
Posts: 6
Hi guys,

After creating a small program that lists files, how would I go about craeting a process that scans the directory for changes and reports them. The lastModified() method just shows the date and time of last modification. There must be a more efficient way to do this, right?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you're right on track with listing the files and examining the lastModified() time. For recent changes, compare last modified to whatever you define as "recent" or the last time you ran.


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
Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48
In terms of efficiency, I don't think there's any way to make this operation any faster than O(n).

In terms of implementation, I think it might turn out a bit tedious to keep track of all the last modified dates for all the files -- especially if you have a lot of files.

Instead, try generating a hash for all the files within a directory (recursive operation). This way you only have to keep track of one number, as opposed to possibly thousands of last modified dates. If the hashes don't match that means something has changed.


SCJP, SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reporting changes (help please!)
 
Similar Threads
For those of you who love Google....
Using HashMap Problem
Sun Certification ??
Java Language Specification for Java 6
J2EE Security for Servlets - 2.4 changes?