This second example covers the exciting world of the new WatchService API and its associated classes.
第二个例子展示了新watchserviceAPI及其相关类的精彩世界。
Whether you hang onto this reference or not is up to you, because the WatchService returns the relevant WatchKey to you when an event is triggered.
是否挂接到这个引用由您决定,因为触发事件后,WatchService会返回相关的WatchKey。
Now that our Path is registered, we can check in with the WatchService at our convenience to see if any of the events we were interested in has occurred.
现在已注册了Path,我们可以用很方便的方式来检查WatchService,看是否发生了任何我们感兴趣的事件。
When you're done with a particular WatchKey and the events it's registered for, you can cancel its registration with the WatchService simply by calling its cancel method.
当您在处理特定WatchKey及其所注册的事件时,可以很简单地通过调用cancel方法,来取消其在WatchService的注册。
When you're done with a particular WatchKey and the events it's registered for, you can cancel its registration with the WatchService simply by calling its cancel method.
当您在处理特定WatchKey及其所注册的事件时,可以很简单地通过调用cancel方法,来取消其在WatchService的注册。
应用推荐