public class LineReadWatcher extends SimpleWatcher implements Runnable
Constructor and Description |
---|
LineReadWatcher(RandomAccessFile randomAccessFile,
Charset charset,
SerConsumer<String> lineHandler)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
onModify(WatchEvent<?> event,
WatchKey key)
文件修改时执行的方法
文件修改可能触发多次 |
void |
run() |
onCreate, onDelete, onOverflow
public LineReadWatcher(RandomAccessFile randomAccessFile, Charset charset, SerConsumer<String> lineHandler)
randomAccessFile
- RandomAccessFile
charset
- 编码lineHandler
- 行处理器SerConsumer
实现public void onModify(WatchEvent<?> event, WatchKey key)
Watcher
onModify
in interface Watcher
onModify
in class SimpleWatcher
event
- 事件,可通过WatchEvent.context()
获取创建的文件或目录名称key
- 事件发生的WatchKey
,可以通过WatchKey.watchable()
获取监听的Path路径Copyright © 2025. All rights reserved.