public static void dirMonitor(String uri){
        try {
            //
            // Creates a instance of WatchService.
            //
            WatchService watcher = FileSystems.getDefault().newWatchService();
 
            //
            // Registers the logDir below with a watch service.
            //
            Path logDir = Paths.get(uri);
            logDir.register(watcher,
                    ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE);
 
            //
            // Monitor the logDir at listen for change notification.
            //
            while (true) {
                WatchKey key = watcher.take();
                for (WatchEvent<?> event : key.pollEvents()) {
                    WatchEvent.Kind<?> kind = event.kind();
 
                    if (kind == ENTRY_CREATE) {
                        System.out.println("Entry was created on log dir.");
                    } else if (kind == ENTRY_MODIFY) {
                        System.out.println("Entry was modified on log dir.");
                    } else if (kind == ENTRY_DELETE) {
                        System.out.println("Entry was deleted from log dir.");
                    }
                }
                key.reset();
            }
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }