Skip to content

Instantly share code, notes, and snippets.

@VenkataRaju
Created December 10, 2015 09:11
Show Gist options
  • Save VenkataRaju/86bc2da60018b930d617 to your computer and use it in GitHub Desktop.
Save VenkataRaju/86bc2da60018b930d617 to your computer and use it in GitHub Desktop.
Path path = Paths.get("D:\\Directory");
WatchService watchService = path.getFileSystem().newWatchService();
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE);
System.out.println("Watching...");
for (;;)
{
WatchKey wk = watchService.take();
wk.pollEvents().forEach(we -> System.out.println(we.context() + ", " + we.kind() + ", " + we.count()));
wk.reset();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment