public class DelayWatcher extends Object implements Watcher
WatchService
多个modify的问题Constructor and Description |
---|
DelayWatcher(Watcher watcher,
long delay)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
onCreate(WatchEvent<?> event,
Path currentPath)
文件创建时执行的方法
|
void |
onDelete(WatchEvent<?> event,
Path currentPath)
文件删除时执行的方法
|
void |
onModify(WatchEvent<?> event,
Path currentPath)
文件修改时执行的方法
文件修改可能触发多次 |
void |
onOverflow(WatchEvent<?> event,
Path currentPath)
事件丢失或出错时执行的方法
|
public DelayWatcher(Watcher watcher, long delay)
watcher
- 实际处理触发事件的监视器Watcher
,不可以是DelayWatcher
delay
- 延迟时间,单位毫秒public void onModify(WatchEvent<?> event, Path currentPath)
Watcher
public void onCreate(WatchEvent<?> event, Path currentPath)
Watcher
public void onDelete(WatchEvent<?> event, Path currentPath)
Watcher
public void onOverflow(WatchEvent<?> event, Path currentPath)
Watcher
onOverflow
in interface Watcher
event
- 事件currentPath
- 事件发生的当前Path路径Copyright © 2024. All rights reserved.