public static boolean createFileWatcher(Path file,FileChangedListener listener){
  if (listener == null || file == null) {
    return false;
  }
  try {
    FileWatcher watcher=new FileWatcher(file,listener);
    Thread thread=new Thread(watcher);
    thread.start();
    LOGGER.info("Added file watcher for: " + file.toAbsolutePath());
    return true;
  }
 catch (  IOException ex) {
    LOGGER.warning("Error adding file watcher for: " + file.toAbsolutePath() + " ["+ ex+ "]");
    return false;
  }
}

public static boolean createFileWatcher ( Path file , FileChangedListener listener ) { if ( listener == null || file == null ) { return false ; } try { FileWatcher watcher = new FileWatcher ( file , listener ) ; Thread thread = new Thread ( watcher ) ; thread . start ( ) ; LOGGER . info ( "Added file watcher for: " + file . toAbsolutePath ( ) ) ; return true ; } catch ( IOException ex ) { LOGGER . warning ( "Error adding file watcher for: " + file . toAbsolutePath ( ) + " [" + ex + "]" ) ; return false ; } }
create a watcher that informs the given listener that the given file was modified . the watcher is run in it ' s own thread . the watcher accumulates events so it takes a few seconds after a modification for the listener to be informed .
