org.apache.commons.io.input.TailerListener Java Examples
The following examples show how to use
org.apache.commons.io.input.TailerListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CsvStreamReader.java From Quicksql with MIT License | 6 votes |
/** * 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); } }
Example #2
Source File: TailingVerifier.java From app-maven-plugin with Apache License 2.0 | 6 votes |
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(); }
Example #3
Source File: CsvStreamReader.java From calcite with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #4
Source File: LogTailer.java From micro-server with Apache License 2.0 | 5 votes |
public void tail(TailerListener listener) { File file = new File( fileLocation); Tailer tailer = Tailer.create(file, listener, 10); tailer.run(); }
Example #5
Source File: LogTailer.java From micro-server with Apache License 2.0 | 5 votes |
public void tail(TailerListener listener, String alias) { File file = logLookup.map(l -> l.lookup(alias)) .orElse(new File( fileLocation)); Tailer tailer = Tailer.create(file, listener, 10); tailer.run(); }
Example #6
Source File: FileTailer.java From websockets-log-tail with Apache License 2.0 | 5 votes |
public Observable<String> getStream(final long pollIntervalMs) { return Observable.create(new ObservableOnSubscribe<String>() { @Override public void subscribe(ObservableEmitter<String> emitter) throws Exception { TailerListener listener = createListener(emitter); final Tailer tailer = new Tailer(file, listener, pollIntervalMs); try { tailer.run(); } catch (Throwable e) { emitter.onError(e); } } }); }