축 어적으로 https://www.dazhuanlan.com/2019/08/25/5d625ec2c8207/
직접 코드에
1 |
경로 경로 = Paths.get ( "경로" ); 경우 (Files.exists (경로)) { 시도 (WatchService watchService FileSystems.getDefault = () newWatchService ().) { path.register ( watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE ); 반면 ( 참 ) { WatchKey 키 watchService.take = (); //阻塞에 대한 (<?> WatchEvent 이벤트 : key.pollEvents ()) { |
몇 가지주의 사항
- 경우에 등록, 하나의 문서의 모니터링을 지원하지 않습니다
path
하지文档夹
던져java.nio.file.NotDirectoryException