Package java.nio.file

Examples of java.nio.file.Path.register()


    try {
      final WatchService watcher = FileSystems.getDefault()
          .newWatchService();
      final Path dir = Paths.get(Constants.DATA_PATH + "playlist/");
      dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);

      System.out.println("Watch Service registered for dir: "
          + dir.getFileName());

      while (true) {
View Full Code Here


   * @throws InterruptedException
   */
  public static void main(String[] args) throws IOException, InterruptedException {
    Path rootDir = Paths.get("new","directory2");
    WatchService watchService = FileSystems.getDefault().newWatchService();
    rootDir.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);

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

    stopped = false;
    init();
    folderWatcher = FileSystems.getDefault().newWatchService();
    Path watchedFolder = Paths.get(iosServerConfiguration.getAppFolderToMonitor());
    try {
      watchedFolder.register(folderWatcher, StandardWatchEventKinds.ENTRY_CREATE,
                             StandardWatchEventKinds.ENTRY_MODIFY,
                             StandardWatchEventKinds.ENTRY_DELETE);
    } catch (NoSuchFileException e) {
      stop();
      log.warning("invalid location: " + new File(iosServerConfiguration.getAppFolderToMonitor())
View Full Code Here

public class WatchMe {
    public static void main(String[] args) {
        Path currentDirectory = Paths.get(System.getProperty("java.io.tmpdir"));

        try (WatchService watchService = FileSystems.getDefault().newWatchService()) {
            WatchKey watchKey = currentDirectory.register(watchService, ENTRY_CREATE, ENTRY_DELETE,
                    ENTRY_MODIFY);
           
            do {
                watchKey = watchService.take();
View Full Code Here

    WatchService watcher = FileSystems.getDefault().newWatchService();

    Path dir = Paths.get(dirIn);
    try {
      dir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE);
    } catch (IOException x) {
      System.err.println(x);
    }

    for (;;) {
View Full Code Here

  public void execute() throws MojoExecutionException {
    try {
      WatchService watcher = FileSystems.getDefault().newWatchService();
      Path inputPath = getInputFile().toPath();
      Path dir = inputPath.getParent();
      dir.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
      getLog().info("Watching " + inputPath + " for changes");
      generate();
      boolean valid = true;
      while (valid) {
        WatchKey key = watcher.take();
View Full Code Here

    WatchService ws = fs.newWatchService();

    fs.close();

    try {
      p.register(ws, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
      fail();
    } catch (ClosedWatchServiceException expected) {
    }

    try {
View Full Code Here

        myWatchService = fs.newWatchService();
        myKeys = new ConcurrentHashMap<WatchKey, Path>();
        mySessionHashCode = aSessionHashCode;

        // Register the path of the log files with our watch service
        myKeys.put(logPath.register(myWatchService, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY), logPath);
    }

    @Override
    public void interrupt() {
        super.interrupt();
View Full Code Here

    try {
      WatchService watcher = FileSystems.getDefault().newWatchService();

      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) {
View Full Code Here

  public void run() {
    try {
      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) {
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.