Java Watchable check for events forever
How to set java watchable to check for events forever ? I mean I'm getting the event's simply with 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;
}
}
But it 开发者_StackOverflowget's them only once, and then terminate .
while(true) { //your code }. Make sure you have some exit condition in while loop else this will be infinite.
精彩评论