Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

watch a folder

 
Cyril Lavy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer: no. Java doesn't have an API for this.
 
Cyril Lavy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK! thanks...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic