Skip to content

Convenient file watcher with an RxJava interface, based on JDK WatchService

License

Notifications You must be signed in to change notification settings

fangqiao/rxfilewatcher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RxFileWatcher allows you to observe directories (recursively or not) for file system events with a RxJava observable. It is based on the JDK WatchService, but it is much more convenient.

Usage

The following example creates an observable that watches the given directory and all its subdirectories for file system events. Directories which are created later are watched, too. Each event will be emitted as a WatchEvent.

PathObservables
  .watchRecursive(Paths.get("some/directory/"))
  .subscribe(event -> System.out.println(event));

To watch only the top-level directory, you call watchNonRecursive instead of watchRecursive:

PathObservables
  .watchNonRecursive(Paths.get("some/directory/"))
  .subscribe(event -> System.out.println(event));

That's it!

See RxJava Documentation for more information, e. g. how you can filter certain types of events.

About

Convenient file watcher with an RxJava interface, based on JDK WatchService

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%