本文整理汇总了Java中org.apache.commons.io.input.TailerListenerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java TailerListenerAdapter类的具体用法?Java TailerListenerAdapter怎么用?Java TailerListenerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TailerListenerAdapter类属于org.apache.commons.io.input包,在下文中一共展示了TailerListenerAdapter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTailingLog
import org.apache.commons.io.input.TailerListenerAdapter; //导入依赖的package包/类
private void startTailingLog() {
TailerListener listener = new TailerListenerAdapter() {
@Override
public void handle(String line) {
System.out.println(testName + ": " + line);
}
};
// Tail the log
File file = new File(getBasedir() + File.separator + getLogFileName());
try {
if (file.exists()) {
file.delete();
}
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Tailer tailer = new Tailer(file, listener, TAIL_DELAY_MILLIS);
Thread thread = new Thread(tailer);
thread.setDaemon(true);
thread.start();
}
示例2: createListener
import org.apache.commons.io.input.TailerListenerAdapter; //导入依赖的package包/类
private TailerListener createListener() {
return new TailerListenerAdapter() {
@Override
public void fileRotated() {
// ignore, just keep tailing
}
@Override
public void handle(String line) {
session.getAsyncRemote().sendText(line);
}
@Override
public void fileNotFound() {
session.getAsyncRemote().sendText(new FileNotFoundException(logFile.toString()).toString());
}
@Override
public void handle(Exception ex) {
session.getAsyncRemote().sendText(ex.toString());
}
};
}
示例3: createListener
import org.apache.commons.io.input.TailerListenerAdapter; //导入依赖的package包/类
private TailerListenerAdapter createListener(
final Observer<? super String> observer) {
return new TailerListenerAdapter() {
@Override
public void fileRotated() {
// ignore, just keep tailing
}
@Override
public void handle(String line) {
observer.onNext(line);
}
@Override
public void fileNotFound() {
observer.onError(new FileNotFoundException(file.toString()));
}
@Override
public void handle(Exception ex) {
observer.onError(ex);
}
};
}