• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Watch files in directory

 
Torben Riis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would like to monitor for new files or whether files has changed in directory. I know I could just make it all from the button, but does anyone know or could recommend a good framework that does the job. Maybe a framework where you can add an observer to get notifications about which file has changed?

Kind regards
Torben Riis
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has been asked often enough that you might find something out there. Spend some time with Google and let us know what you find.

If you decide to write something you have a couple choices. One is to write a C/C++ module that uses operating system APIs and wire that up to your Java program with JNI. It's not portable, but could be pretty cool. Another is to read the list of current files into some structure, then do it again every few minutes and compare lists to find new things. Or just comparing timestamps to the last time you ran might meet your requirements. Or not.

To list all files in a folder and all subfolders, the new DZone Snippets site has a cute File Iterator. You'll have to search around for his FlatteningIterator, too.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic