aspose file tools*
The moose likes Beginning Java and the fly likes watch a folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "watch a folder" Watch "watch a folder" New topic
Author

watch a folder

Cyril Lavy
Greenhorn

Joined: Nov 18, 2003
Posts: 7
Hello,
Is there a way to watch constantly the changes of a directory including sub-folder and then perform an action if a file has been added, deleted, modified...?
Thanks in advance!
Cyril Lavy
Greenhorn

Joined: Nov 18, 2003
Posts: 7
...without having to scan all the subdirs and compare every file? In fact it is more some kind of process that gets the system's actions when file deleted, saved, etc...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Short answer: no. Java doesn't have an API for this.


[Jess in Action][AskingGoodQuestions]
Cyril Lavy
Greenhorn

Joined: Nov 18, 2003
Posts: 7
OK! thanks...
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
A wee bit longer answer:
It wouldn't be too difficult to develop such a utility making good use of Observer and Observable, and Java Threads.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
But the observer... thread need scan directory, and check each file
(by modification date, or digital digest, ....).
You alwais can write it in JNI, but it will be system dependant.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: watch a folder