Class ExtendedWatchEventModifier


  • public class ExtendedWatchEventModifier
    extends java.lang.Object
    This class holds non-standard modifiers that can be passed to Path.register(). Note that these might not be supported on all platforms, so specifying them to register might cause an UnsupportedOperationException or an IllegalArgumentException to be thrown.
    • Field Detail

      • FILE_TREE

        public static final WatchEvent.Modifier<Path> FILE_TREE
        The FILE_TREE modifier makes a WatchKey recursive. Without this modifier, a file watch is shallow: For a watched directory foo, WatchEvents are only generated for direct children such as foo/bar or foo/oof. For a changes to files in a subdirectory of foo, such as foo/adir/file will only be reported if the FILE_TREE modifier is specified. Note that this modifier is only available on the Windows platform. If specified on other platforms, Path.register() will throw an UnsupportedOperationException.
      • ACCURATE

        public static final WatchEvent.Modifier<Path> ACCURATE
        The ACCURATE modifier indicates that the WatchKey may not miss events under any circumstances.

        If a WatchService implementation is based on polling it may miss files that are created and deleted between two polls of the key (see below how this can happen). The ACCURATE modifier demands that no events may be missed, however, not all platforms support this.

        Note that even without specifying ACCURATE events are still guaranteed to be reported as symmetric - if both ENTRY_CREATE and ENTRY_DELETE have been specified, only whole pairs of creation/deletion can be missed, not just one of them.

        On some platforms, ACCURATE is implicit as the underlying operating system guarantees to deliver every event, even without specifying ACCURATE (however, the queue might still overflow, generating an event of the OVERFLOW kind)

        Consider the following scenario in which an implementation which does not support ACCURATE can miss events:
        Say, at 0ms, the key polls, and detects no files in a directory. The key goes to sleep for 200ms. Say, at 50ms, a file is created. Then, at 100ms, the same file is deleted again. When the WatchKey wakes up after 200ms, it will see the same as it saw before: An empty directory.

    • Constructor Detail

      • ExtendedWatchEventModifier

        public ExtendedWatchEventModifier()