如何设置java watchable永远检查事件?我的意思是我只是简单地使用if ..
for (WatchEvent event : events) {
boolean terminate_or = false;
if (event.kind() == StandardWatchEventKind.ENTRY_CREATE) {
System.out.println("Created: " + event.context().toString());
event.
}
if (event.kind() == StandardWatchEventKind.ENTRY_DELETE) {
System.out.println("Delete: " + event.context().toString());
terminate_or = true;
}
if (event.kind() == StandardWatchEventKind.ENTRY_MODIFY) {
System.out.println("Modify: " + event.context().toString());
terminate_or = true;
}
}
但是它只有一次,然后终止。
答案 0 :(得分:1)
while(true){//您的代码}。确保你在while循环中有一些退出条件,否则这将是无限的。