类org.apache.commons.io.input.TailerListenerAdapter源码实例Demo

下面列出了怎么用org.apache.commons.io.input.TailerListenerAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: konduit-serving   文件: LogsCommand.java
private void readAndTail(File logsFile, int fromNumberOfLines) throws IOException {
    new Tailer(logsFile, StandardCharsets.UTF_8, new TailerListenerAdapter() {
        @SneakyThrows
        @Override
        public void init(Tailer tailer) {
            super.init(tailer);
            if(fromNumberOfLines != -1) {
                out.println(LauncherUtils.readLastLines(logsFile, fromNumberOfLines));
            }
        }

        @Override
        public void handle(String line) {
            out.println(line);
        }

        @Override
        public void handle(Exception ex) {
            ex.printStackTrace();
            System.exit(1);
        }
    }, 100, fromNumberOfLines != -1, false, 4096).run();
}
 
源代码2 项目: app-maven-plugin   文件: TailingVerifier.java
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();
}
 
源代码3 项目: websockets-log-tail   文件: FileTailer.java
private TailerListenerAdapter createListener(final ObservableEmitter<String> emitter) {
    return new TailerListenerAdapter() {

        @Override
        public void fileRotated() {
            // ignore, just keep tailing
        }

        @Override
        public void handle(String line) {
            emitter.onNext(line);
        }

        @Override
        public void fileNotFound() {
            emitter.onError(new FileNotFoundException(file.toString()));
        }

        @Override
        public void handle(Exception ex) {
            emitter.onError(ex);
        }
    };
}
 
源代码4 项目: bidder   文件: PipeTailer.java
/**
 * Create a named pipe subscriber
 * @param handler TailerListenerAdaptor. The parent, the thing that consumes the message.
 * @param fileName String. The name of the pipe.
 * @throws Exception if the file does not exist or what is named is not a file.
 */
public PipeTailer(TailerListenerAdapter handler, String fileName) throws Exception {
    this.handler = handler;
    this.fileName = fileName;
    File f_pipe = new File(fileName);
    if (!f_pipe.exists())
        throw new Exception("Named pipe: " + fileName + " does not exist");
    if (!f_pipe.isFile()==false)
        throw new Exception(fileName + " is not a pipee");
    me = new Thread(this);
    me.start();

}
 
 类所在包
 同包方法