Getting to modify events on changes in file?
I am using Watch Service API of nio.2 classes to watch a specific directory( Ubuntu 11.10). whenever a change is made, for eg if I modify in existing file, it fires a MODIFIED event 2 times. Don't know why? it's work fine when I create new file.
I found a solution for it. It fires two modify events, because when the filesystem writes new files, it creates it with zero byte and fires create event and then it writes data to the and file then it fires the modify event.
The same applies with modifications. When we modify an already existing file, the filesystem first creates it with 0 bytes and fires a modify event and then writes data to it. Then it fires the modify event again. That's why I was receiving two modify events.