Currently doing a simillar thing. I implemented a Thread(s) that wakes up every 10 seconds to check if a file came in or not. Looks like in your case you will need to know what files were there to begin with etc.
Write an interface Monitor with methods like addMonitor and removeMonitor and you can monitor the folder for any type of files by listing all files in the folder and checking their extension. If found you can invoke a filefound() method or a listener registered with this. Just a vague idea
Originally posted by hatim osman: Hi there Is there way I can monitor a particular folder, new files added, renamed or deleted? I want so some sort of a listener, if possible of course.
Other actions can be deduced but i am really not sure about how a rename action can be deduced i.e. how do you differentiate between a file deleted and a new created and one is renamed to other? I dont think there is a way to find out whether the file/directory has been renamed unless OS gives you a callback for this(which as william pointed out is not available.) Since, you can not have a listener for directory modification events, so you have to write a deamon that wakes up after a configured interval of time and checks the state of the dir with the last state. There can be an optimization(as william pointed) that you can check the last modified time of the directory with the last time it was scanned. But, this depends on the OS whether it updates the time modified of the directory for actions taken on any of the files and sub-directories directly by the OS or through other application. (I validated it with windows vista, the directory time does not change if i modify any of its file using my IDE.)