private void handleEvent ( final WatchKey key ) { try { key . pollEvents ( ) . forEach ( event -> { val eventName = event . kind ( ) . name ( ) ; val ev = ( WatchEvent < Path > ) event ; val filename = ev . context ( ) ; val parent = ( Path ) key . watchable ( ) ; val fullPath = parent . resolve ( filename ) ; val file = fullPath . toFile ( ) ; LOGGER . trace ( "Detected event [{}] on file [{}]" , eventName , file ) ; if ( eventName . equals ( ENTRY_CREATE . name ( ) ) && file . exists ( ) ) { onCreate . accept ( file ) ; } else if ( eventName . equals ( ENTRY_DELETE . name ( ) ) ) { onDelete . accept ( file ) ; } else if ( eventName . equals ( ENTRY_MODIFY . name ( ) ) && file . exists ( ) ) { onModify . accept ( file ) ; } } ) ; } catch ( final Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } }
Handle event .