支持的事件类型在StandardWatchEventKinds中定义。
import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.Paths;/** n o w j a v a . c o m - 时代Java 提 供 **/ import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchService; public class Main { public static void main(String[] args) throws Exception { final Path path = Paths.get("C:/folder1"); WatchService watchService = FileSystems.getDefault().newWatchService(); path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE,