I am being able to use Jnotify
for listening events as file cration, modification etc. My concern is how Jnotify works. I mean what it uses get event. Is it safe to use in refrence of resource uses. I read in another SO question -- https://stackoverflow.com/questions/11100003/why-does-jnotify-consume-so-much-resources -- that it consume much resources.
Another way I can solve my problem is a while loop till a condition then program is shutdown.
Which will be better to use consumes less resources.
From the site...
The limitations are documented. Also gives idea about implementation.
Your problem is related to File changed listener in Java , the highly voted answer there is DefaultFileMonitor, from Apache commons. I suggest you give it a try.
linnotify talks to the kernel to get notified of filesystem changes. No polling, the kernel notifies on changes to the subscribed folders.
jnotify is a JNI wrapper around libjnotify.
Nonetheless, if you are using Java 7, all that is history, replaced by the new java file I/O (NIO.2) package.