开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜