Package java.nio.file

Examples of java.nio.file.WatchKey.reset()


        for (WatchEvent<?> event : key.pollEvents()) {
          if (event.kind() == ENTRY_MODIFY) {
            System.out.println("Home dir changed!");
          }
        }
        key.reset();
      }
    } catch (IOException | InterruptedException e) {
      System.out.println(e.getMessage());
    }
  }
View Full Code Here


            watcher.handleDeleteEvent(key, (Path) event.context());
          }
        }

        /* Reset the Key to get more events later */
        if (!key.reset()) {
          for (DirectoryWatcher watcher : watchers) {
            watcher.handleKeyInvalid(key);
          }
        }
      }
View Full Code Here

            key.cancel();
         }
         else
         {
            // reset key and remove from set if directory no longer accessible
            boolean valid = key.reset();
            if (!valid)
            {
               keys.remove(key);
            }
         }
View Full Code Here

                  {
                     logger.log(Level.INFO, "Detected changes in repository [" + events.iterator().next().context()
                              + "].");
                     dirty = true;
                  }
                  key.reset();
                  key = watcher.poll();
               }

               if (dirty)
               {
View Full Code Here

                    x.printStackTrace();
                }
            }

            // reset key and remove from set if directory no longer accessible
            boolean valid = key.reset();
            if (!valid) {
                LOGGER.debug("Removing key " + key + " and dir " + dir + " from keys");
                keys.remove(key);

                // all directories are inaccessible
View Full Code Here

            key.cancel();
         }
         else
         {
            // reset key and remove from set if directory no longer accessible
            boolean valid = key.reset();
            if (!valid)
            {
               keys.remove(key);
            }
         }
View Full Code Here

            }

            // Reset the key -- this step is critical to receive
            // further watch events. If the key is no longer valid, the directory
            // is inaccessible so exit the loop.
            if (!key.reset()) {
                break;
            }
        }
    }
}
View Full Code Here

                    Path name = dir.resolve(ev.context());
                    if (file.equals(name)) {
                        encryptedPassword(new Properties(file.toFile()));
                    }
                }
                key.reset();
            }

        } catch (ClosedWatchServiceException | InterruptedException e) {
            // Ignore
        } catch (IOException e) {
View Full Code Here

  protected boolean pollEvents() throws Exception {
    // Take events, but don't care what they are!
    WatchKey watchKey = watchService.take();
   
    watchKey.pollEvents();
    watchKey.reset();
   
    // Events are always relevant; ignored paths are not monitored
    return true;
  }
View Full Code Here

      WatchKey key = directory.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE);
      if(key.isValid()){
        process(key);
      }

      while(key.reset()){

        try {
          key = watcher.take();
        } catch(InterruptedException ie){
          break;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.