Package org.oddjob.io

Interface FileWatch

All Known Implementing Classes:
FileWatchService

public interface FileWatch
Watch for a single file to exist or modification.
  • Method Summary

    Modifier and Type
    Method
    Description
    subscribe(Path path, Consumer<? super InstantEvent<Path>> consumer)
    Subscribe to notifications for the existence or modifications in the file.
  • Method Details

    • subscribe

      Restore subscribe(Path path, Consumer<? super InstantEvent<Path>> consumer)
      Subscribe to notifications for the existence or modifications in the file.

      If the file exists already the consumer will be notified before this method returns. If the file is created during the call to this method then the consumer may receive a notification for the same file twice. A consumer could use the modified date to remove duplicated but then may miss file modifications that happen close together. The documentation for implementations should adequately explain such behaviours.

      Parameters:
      path - The path of the file to watch. Must not be null.
      consumer -
      Returns:
      Something that will close resources.