on August 30, 2010 at 7:32 AM PDT
I'm attempting to transition a project that uses the Inotify-Java library (Linux only) over to the JDK 7 WatchService API.
My problem is the following:
I can't figure out a straightforward way to detect when the writing of a file to a watched directory has completed. Inotify-Java provides a "CLOSE_WRITE" event that allows me to detect exactly this condition; however, I don't see a ready way to do this using the JDK 7 provided StandardWatchEventKind types.
The problem with StandardWatchEventKind.ENTRY_MODIFY is that I receive hundreds of them through the WatchService instance when a larger file is being copied into a watched directory. The "processing" on this file only needs to be done once and only after the file is completely written out to the watched directory.
Am I missing an easy way to solve my problem with the JDK 7 WatchService API, or is the limited number of WatchEvent.Kind types the tradeoff in order to support multiple OS types (e.g., Windows and Linux)?