All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.takari.watcher.MyDirectoryWatcher Maven / Gradle / Ivy

package io.takari.watcher;

import java.io.IOException;
import java.nio.file.Path;

public class MyDirectoryWatcher {

  private final Path pathToWatch;

  public MyDirectoryWatcher(Path pathToWatch) {
    this.pathToWatch = pathToWatch;
  }

  public void watch() throws Exception {
    DirectoryWatcher watcher = DirectoryWatcher.builder().directory(pathToWatch).listener(new DirectoryChangeListener() {
      @Override
      public void onCreate(Path path) throws IOException {
        // process create
      }

      @Override
      public void onModify(Path path) throws IOException {
        // process modifiy
      }

      @Override
      public void onDelete(Path path) throws IOException {
        // process delete
      }
    }).build();
    watcher.processEvents();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy