Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

watch service java

Path path = Paths.get(".");
WatchService watchService =  path.getFileSystem().newWatchService();
path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);

WatchKey watchKey = null;
while (true) {
    watchKey = watchService.poll(10, TimeUnit.MINUTES);
    if(watchKey != null) {
        watchKey.pollEvents().stream().forEach(event -> System.out.println(event.context()));
    }
    watchKey.reset();
}
Source by howtodoinjava.com #
 
PREVIOUS NEXT
Tagged: #watch #service #java
ADD COMMENT
Topic
Name
7+8 =