开发者

Java Watchable check for events forever

开发者 https://www.devze.com 2023-03-04 22:54 出处:网络
How to set java watchable to check for events forever ? I mean I\'m getting the event\'s simply with if ..

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

精彩评论

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