http://blog.csdn.net/chenyi8888/article/details/8517335
http://www.ibm.com/developerworks/cn/education/java/j-nio/ NIO系列学习链接
http://www.ibm.com/developerworks/cn/java/j-nio2-1/ NIO2
public class Watcher {
public static void main(String[] args) {
Path dir = Paths.get("D:/video");
try {
WatchService watcher = dir.getFileSystem().newWatchService();
dir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE);
WatchKey watchKey = watcher.take();
List<WatchEvent<?>> events = watchKey.pollEvents();
for (WatchEvent<?> event : events) {
System.out.println("Someone just created the file '"
+ event.context().toString() + "'.");
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}