当前位置: 首页>>代码示例>>Java>>正文


Java TailerListener类代码示例

本文整理汇总了Java中org.apache.commons.io.input.TailerListener的典型用法代码示例。如果您正苦于以下问题:Java TailerListener类的具体用法?Java TailerListener怎么用?Java TailerListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TailerListener类属于org.apache.commons.io.input包,在下文中一共展示了TailerListener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startTailingLog

import org.apache.commons.io.input.TailerListener; //导入依赖的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();
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-maven-plugin,代码行数:24,代码来源:TailingVerifier.java

示例2: createListener

import org.apache.commons.io.input.TailerListener; //导入依赖的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());
            }
        };
    }
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:26,代码来源:ServerLogsTailer.java

示例3: CsvStreamReader

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
/**
 * Creates a CsvStreamReader with supplied separator and quote char.
 *
 * @param source The file to an underlying CSV source
 * @param separator The delimiter to use for separating entries
 * @param quoteChar The character to use for quoted elements
 * @param escape The character to use for escaping a separator or quote
 * @param line The line number to skip for start reading
 * @param strictQuotes Sets if characters outside the quotes are ignored
 * @param ignoreLeadingWhiteSpace If true, parser should ignore
 *  white space before a quote in a field
 */
private CsvStreamReader(Source source, char separator, char quoteChar,
    char escape, int line, boolean strictQuotes,
    boolean ignoreLeadingWhiteSpace) {
  super(new StringReader("")); // dummy call to base constructor
  contentQueue = new ArrayDeque<>();
  TailerListener listener = new CsvContentListener(contentQueue);
  tailer = Tailer.create(source.file(), listener, DEFAULT_MONITOR_DELAY,
      false, true, 4096);
  this.parser = new CSVParser(separator, quoteChar, escape, strictQuotes,
      ignoreLeadingWhiteSpace);
  this.skipLines = line;
  try {
    // wait for tailer to capture data
    Thread.sleep(DEFAULT_MONITOR_DELAY);
  } catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:CsvStreamReader.java

示例4: tail

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
public void tail(TailerListener listener) {

        File file = new File(
                             fileLocation);
        Tailer tailer = Tailer.create(file, listener, 10);

        tailer.run();
    }
 
开发者ID:aol,项目名称:micro-server,代码行数:9,代码来源:LogTailer.java

示例5: initNetlogTailer

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
private void initNetlogTailer() {
    
    if (netLogTailerThread != null) {
        netLogTailerThread.interrupt();
        netLogTailerThread = null;
    }
    
    if (activeNetLogFile != null) {
        TailerListener listener = new NetLogTailerListener();
        Tailer tailer = new Tailer(activeNetLogFile, listener, 2000);
        this.netLogTailerThread = new Thread(tailer);
        netLogTailerThread.setDaemon(true);
        netLogTailerThread.start();
    }
}
 
开发者ID:jrosocha,项目名称:jarvisCli,代码行数:16,代码来源:LogFileService.java

示例6: getStream

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
public Observable<String> getStream(final long pollIntervalMs) {
	return Observable.create(new OnSubscribeFunc<String>() {

		@Override
		public Subscription onSubscribe(
				final Observer<? super String> observer) {
			TailerListener listener = createListener(observer);
			final Tailer tailer = new Tailer(file, listener, pollIntervalMs);
			Thread t = new Thread(createRunnable(observer, tailer));
			t.start();
			return createSubscription(tailer);
		}
	});
}
 
开发者ID:davidmoten,项目名称:websockets-log-tail,代码行数:15,代码来源:FileTailer.java

示例7: GzipTailer

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
/**
 * Creates a Tailer for the given file, with a specified buffer size.
 *
 * @param file        the file to follow.
 * @param listener    the TailerListener to use.
 * @param delayMillis the delay between checks of the file for new content in milliseconds.
 * @param end         Set to true to tail from the end of the file, false to tail from the beginning of the file.
 * @param bufSize     Buffer size
 */
public GzipTailer(File file, TailerListener listener, long delayMillis, boolean end, int bufSize)
{
    super(file, listener, delayMillis, end, bufSize);

    this.file = file;
    this.delayMillis = delayMillis;
    this.end = end;

    this.inbuf = new byte[bufSize];

    // Save and prepare the listener
    this.listener = listener;
    listener.init(this);
}
 
开发者ID:ustream,项目名称:yolo,代码行数:24,代码来源:GzipTailer.java

示例8: start

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
public void start()
{
	for (Log log : logs)
	{
		TailerListener listener = new MyTailerListener(log);
		executor.execute(new Tailer(log.getFile(), listener, DELAY, false, false));
	}
}
 
开发者ID:caplin,项目名称:ZapLog,代码行数:9,代码来源:Tailing.java

示例9: LogTailer

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
@Autowired
public LogTailer(File file, TailerListener listener, long delayMillis) {

	super(file, listener, delayMillis, TAIL_FROM_END_OF_FILE);
}
 
开发者ID:lcappuccio,项目名称:filtering-ads-with-linux,代码行数:6,代码来源:LogTailer.java

示例10: setupTailer

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
private void setupTailer() {
	TailerListener listener = new LogTailer();
	File tailFile = new File(DebugLogger.LOGGING_FILENAME);
	tailer = Tailer.create(tailFile, new LogTailer(), 500, true);
}
 
开发者ID:Mgamerz,项目名称:me3modmanager,代码行数:6,代码来源:LogWindow.java

示例11: create

import org.apache.commons.io.input.TailerListener; //导入依赖的package包/类
/**
 * Creates and starts a Tailer for the given file.
 *
 * @param file        the file to follow.
 * @param listener    the TailerListener to use.
 * @param delayMillis the delay between checks of the file for new content in milliseconds.
 * @param end         Set to true to tail from the end of the file, false to tail from the beginning of the file.
 * @param bufSize     buffer size.
 * @return The new tailer
 */
public static GzipTailer create(File file, TailerListener listener, long delayMillis, boolean end, int bufSize)
{
    GzipTailer tailer = new GzipTailer(file, listener, delayMillis, end, bufSize);
    Thread thread = new Thread(tailer);
    thread.setDaemon(true);
    thread.start();
    return tailer;
}
 
开发者ID:ustream,项目名称:yolo,代码行数:19,代码来源:GzipTailer.java


注:本文中的org.apache.commons.io.input.TailerListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。