I just tried out your library, as i found the 'pure' java way using the WatchService kind of ugly - nice work to wrap that with this library!
When playing around, I forgot to get my dummy-file's parent directory when I added the path to your DirectoryWatcher's builder. As a result, I got no events when modifying the file.
The WatchService fails with java.nio.file.NotDirectoryException in this case - with your library everything seemed ok and I didn't get any sing of my mistake other than nothing happen...
So my suggestion would be to either fail for non-directory Paths as java does - or, even better, internally just watch the files parent directory and add a filter to get only events for the respective file. That would be really cool... ;-)
DirectoryWatcher.builder()
.path(dummyPath.getParent()) // <- initially, I forgot getPatent() for my dummy-textfile
.listener(event -> System.out.println(" \\-> EVENT = " + event))
.build()
.watchAsync();
I just tried out your library, as i found the 'pure' java way using the
WatchService
kind of ugly - nice work to wrap that with this library!When playing around, I forgot to get my dummy-file's parent directory when I added the path to your
DirectoryWatcher
's builder. As a result, I got no events when modifying the file.The
WatchService
fails withjava.nio.file.NotDirectoryException
in this case - with your library everything seemed ok and I didn't get any sing of my mistake other than nothing happen...So my suggestion would be to either fail for non-directory Paths as java does - or, even better, internally just watch the files parent directory and add a filter to get only events for the respective file. That would be really cool... ;-)