您的位置:首页 > 编程语言 > Java开发

文件变化监视 java.nio.file.WatchService

2015-02-09 17:28 483 查看
WatchKey java.nio.file.Path.register(WatchService watcher, Kind<?>... events) throws IOException

为该文件注册watch service。

Registers the file located by this path with a watch service.

WatchKey java.nio.file.WatchService.take() throws InterruptedException

检索并移除下一个watch key。若没有可检索的则阻塞。

Retrieves and removes next watch key, waiting if none are yet present.

List<WatchEvent<?>> java.nio.file.WatchKey.pollEvents()

检索并移除所有该watch key

Retrieves and removes all pending events for this watch key, returning a List of the events that were retrieved.

Kind<?> java.nio.file.WatchEvent.kind()

返回事件种类

Returns the event kind.

String java.nio.file.WatchEvent.Kind.name()

返回事件种类的名字。

Returns the name of the event kind.

? java.nio.file.WatchEvent.context()

返回事件发生的环境,简单讲就是不带路径的文件名。

Returns the context for the event.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: