本文整理匯總了Java中java.nio.file.WatchEvent.count方法的典型用法代碼示例。如果您正苦於以下問題:Java WatchEvent.count方法的具體用法?Java WatchEvent.count怎麽用?Java WatchEvent.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.file.WatchEvent
的用法示例。
在下文中一共展示了WatchEvent.count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleEvent
import java.nio.file.WatchEvent; //導入方法依賴的package包/類
/**
* Handle event.
*
* @param key the key
*/
private void handleEvent(final WatchKey key) {
this.readLock.lock();
try {
for (final WatchEvent<?> event : key.pollEvents()) {
if (event.count() <= 1) {
final WatchEvent.Kind kind = event.kind();
//The filename is the context of the event.
final WatchEvent<Path> ev = (WatchEvent<Path>) event;
final Path filename = ev.context();
final Path parent = (Path) key.watchable();
final Path fullPath = parent.resolve(filename);
final File file = fullPath.toFile();
LOGGER.trace("Detected event [{}] on file [{}]. Loading change...", kind, file);
if (kind.name().equals(ENTRY_CREATE.name()) && file.exists()) {
handleCreateEvent(file);
} else if (kind.name().equals(ENTRY_DELETE.name())) {
handleDeleteEvent();
} else if (kind.name().equals(ENTRY_MODIFY.name()) && file.exists()) {
handleModifyEvent(file);
}
}
}
} finally {
this.readLock.unlock();
}
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:36,代碼來源:JsonServiceRegistryConfigWatcher.java