private void processFileNotifications ( ) throws InterruptedException , TTException , IOException { while ( true ) { WatchKey key = mWatcher . take ( ) ; Path dir = mKeyPaths . get ( key ) ; for ( WatchEvent < ? > evt : key . pollEvents ( ) ) { WatchEvent . Kind < ? > eventType = evt . kind ( ) ; if ( eventType == OVERFLOW ) continue ; Object o = evt . context ( ) ; if ( o instanceof Path ) { Path path = dir . resolve ( ( Path ) evt . context ( ) ) ; process ( dir , path , eventType ) ; } } key . reset ( ) ; processFsnOnHold ( ) ; } }
In this method the notifications of the filesystem if anything changed in a folder that the system is listening to are being extracted and processed .