public class WatchMonitor extends Thread implements Closeable
Thread.State, Thread.UncaughtExceptionHandler| 限定符和类型 | 字段和说明 |
|---|---|
static WatchEvent.Kind<?>[] |
EVENTS_ALL
全部事件
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| 构造器和说明 |
|---|
WatchMonitor(File file,
WatchEvent.Kind<?>... events)
构造
|
WatchMonitor(Path path,
WatchEvent.Kind<?>... events)
构造
|
WatchMonitor(String path,
WatchEvent.Kind<?>... events)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
关闭监听
|
static WatchMonitor |
create(File file,
WatchEvent.Kind<?>... events)
创建并初始化监听
|
static WatchMonitor |
create(Path path,
WatchEvent.Kind<?>... events)
创建并初始化监听
|
static WatchMonitor |
create(String path,
WatchEvent.Kind<?>... events)
创建并初始化监听
|
static WatchMonitor |
create(URI uri,
WatchEvent.Kind<?>... events)
创建并初始化监听
|
static WatchMonitor |
create(URL url,
WatchEvent.Kind<?>... events)
创建并初始化监听
|
void |
init()
初始化
|
void |
run() |
WatchMonitor |
setWatcher(Watcher watcher)
设置监听
|
void |
watch()
开始监听事件,阻塞当前进程
|
void |
watch(Watcher watcher)
开始监听事件,阻塞当前进程
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic static final WatchEvent.Kind<?>[] EVENTS_ALL
public WatchMonitor(File file, WatchEvent.Kind<?>... events)
file - 文件events - 监听的事件列表public WatchMonitor(String path, WatchEvent.Kind<?>... events)
path - 字符串路径events - 监听的事件列表public WatchMonitor(Path path, WatchEvent.Kind<?>... events)
path - 字符串路径events - 监听事件列表public static WatchMonitor create(URI uri, WatchEvent.Kind<?>... events)
uri - URIevents - 监听的事件列表public static WatchMonitor create(URL url, WatchEvent.Kind<?>... events)
url - URLevents - 监听的事件列表public static WatchMonitor create(File file, WatchEvent.Kind<?>... events)
file - 文件events - 监听的事件列表public static WatchMonitor create(String path, WatchEvent.Kind<?>... events)
path - 路径events - 监听的事件列表public static WatchMonitor create(Path path, WatchEvent.Kind<?>... events)
path - 路径events - 监听事件列表public void init()
IOExceptionpublic WatchMonitor setWatcher(Watcher watcher)
watcher - 监听WatchMonitorpublic void watch()
public void watch(Watcher watcher)
watcher - 监听InterruptedExceptionpublic void close()
close 在接口中 Closeableclose 在接口中 AutoCloseableCopyright © 2017. All rights reserved.