public final class FileChangeWatcher extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FileChangeWatcher.State |
Constructor and Description |
---|
FileChangeWatcher(Path dirPath,
Consumer<WatchEvent<?>> callback)
Creates a watcher that watches
dirPath and invokes callback on changes. |
Modifier and Type | Method and Description |
---|---|
FileChangeWatcher.State |
getState()
Returns the current
FileChangeWatcher.State . |
void |
start()
Tells the background thread to start.
|
void |
stop()
Tells the background thread to stop.
|
public FileChangeWatcher(Path dirPath, Consumer<WatchEvent<?>> callback) throws IOException
dirPath
and invokes callback
on changes.dirPath
- the directory to watch.callback
- the callback to invoke with events. event.kind()
will return the type of event,
and event.context()
will return the filename relative to dirPath
.IOException
- if there is an error creating the WatchService.public FileChangeWatcher.State getState()
FileChangeWatcher.State
.public void start()
public void stop()
Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.