WatchService
对某个文件夹进行监控

WatchService watchService = FileSystems.getDefault().newWatchService();
Path path = FileSystems.getDefault().getPath("C:\\Users\\chaoj\\Desktop\\123");
path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
WatchKey key;
while ((key = watchService.take()) != null) {
for (WatchEvent event : key.pollEvents()){
System.out.println(event.kind()+" "+event.context());
}
key.reset();
}

监控单个文件的变化

for location in self.__locations:
self.__tails.append(TailFollowBookmark(location, 1, self.__bookmark_dir, self._plugin.get('config','encoding')))

在TailFollowBookmark中有方法是通过一个bookmark文件(书签)来记录目前读到哪一行了

tell 返回文件的当前位置
seek 设置文件当前位置