Package java.nio.file

Examples of java.nio.file.WatchService.take()


          + dir.getFileName());

      while (true) {
        WatchKey key;
        try {
          key = watcher.take();
        } catch (final InterruptedException ex) {
          return;
        }

        for (final WatchEvent<?> event : key.pollEvents()) {
View Full Code Here


      }
    }).start();

    for (;;) {
      // retrieve key
      WatchKey key = watcher.take();
      Path parent = map.get(key);
      System.out.println("-----");
      // process events
      for (WatchEvent<?> event : key.pollEvents()) {
        if (event.kind().type() == Path.class) {
View Full Code Here

    WatchService watchService = FileSystems.getDefault().newWatchService();
    rootDir.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);

    WatchKey watchKey;
    while (true) {
      watchKey = watchService.take();
      processEvenKey(watchKey);
      watchKey.reset();
    }
  }
 
View Full Code Here

                WatchService watcher = FileSystems.getDefault().newWatchService();
                Path path = FileSystems.getDefault().getPath(this.modulePath);
                WatchKey key = path.getParent().register(watcher, ENTRY_MODIFY);

                for (;;) {
                    key = watcher.take();
                    for (WatchEvent event: key.pollEvents()) {
                        if (event.kind() == ENTRY_MODIFY){
                            WatchEvent<Path> ev = (WatchEvent<Path>)event;
                            Path filename = ev.context();
                            if (filename.equals(path.getFileName())){
View Full Code Here

        try {
          Path root = Paths.get(path);
          WatchService watcher = root.getFileSystem().newWatchService();
          register(root, watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE);
          while (true) {
            final WatchKey key = watcher.take();
            for (WatchEvent<?> event : key.pollEvents()) {
             
              @SuppressWarnings("unchecked")
              Path item = ((WatchEvent<Path>) event).context();
              Path dir = keys.get(key);
View Full Code Here

    for (;;) {

      WatchKey key;
      try {
        key = watcher.take();
      } catch (InterruptedException x) {
        return;
      }

      for (WatchEvent<?> event : key.pollEvents()) {
View Full Code Here

      dir.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
      getLog().info("Watching " + inputPath + " for changes");
      generate();
      boolean valid = true;
      while (valid) {
        WatchKey key = watcher.take();
        for (WatchEvent<?> event : key.pollEvents()) {
          if (event.kind() == StandardWatchEventKinds.OVERFLOW) {
            continue;
          }
          WatchEvent<Path> ev = (WatchEvent<Path>) event;
View Full Code Here

      Path dir = FileSystems.getDefault().getPath("/usr/karianna");

      WatchKey key = dir.register(watcher, ENTRY_MODIFY);

      while (!shutdown) {
        key = watcher.take();
        for (WatchEvent<?> event : key.pollEvents()) {
          if (event.kind() == ENTRY_MODIFY) {
            System.out.println("Home dir changed!");
          }
        }
View Full Code Here

      Path evdev = Paths.get("/dev/input");
     
      WatchService watcher = evdev.getFileSystem().newWatchService();
      evdev.register(watcher, StandardWatchEventKinds.ENTRY_CREATE);
     
      WatchKey watckKey = watcher.take();
      List<WatchEvent<?>> events = watckKey.pollEvents();
      for (WatchEvent event:events) {
        if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE) {
          String name = event.context().toString();
          if (filter.accept(input, name)) {
View Full Code Here

      }

      while(key.reset()){

        try {
          key = watcher.take();
        } catch(InterruptedException ie){
          break;
        }

        if(key.isValid()){
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.