WatchService: Filter event notification based on filename pattern

134 Views Asked by At

currently i'm using an if statement to filter out watch event based on file name. if there a way for me to only getting notification from certain files based on filename pattern only? Thanks

 if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE) {
          Path item = (Path) event.context();
          Path dir = (Path) key.watchable();
          if(FilenameUtils.getExtension( item.toFile().getName()) == ".xml")
          System.out.println("ENTRY_CREATE: " + item.toFile().getName());
}
0

There are 0 best solutions below