Package org.apache.commons.io.input
Class Tailer.Builder
- java.lang.Object
-
- org.apache.commons.io.build.AbstractSupplier<T,B>
-
- org.apache.commons.io.build.AbstractOriginSupplier<T,B>
-
- org.apache.commons.io.build.AbstractStreamBuilder<Tailer,Tailer.Builder>
-
- org.apache.commons.io.input.Tailer.Builder
-
- All Implemented Interfaces:
IOSupplier<Tailer>
- Enclosing class:
- Tailer
public static class Tailer.Builder extends AbstractStreamBuilder<Tailer,Tailer.Builder>
Builds a newTailer.For example:
Tailer t = Tailer.builder() .setPath(path) .setCharset(StandardCharsets.UTF_8) .setDelayDuration(Duration.ofSeconds(1)) .setExecutorService(Executors.newSingleThreadExecutor(Builder::newDaemonThread)) .setReOpen(false) .setStartThread(true) .setTailable(tailable) .setTailerListener(tailerListener) .setTailFromEnd(false) .get();- Since:
- 2.12.0
- See Also:
get()
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tailerget()Builds a newTailer.Tailer.BuildersetDelayDuration(java.time.Duration delayDuration)Sets the delay duration.Tailer.BuildersetExecutorService(java.util.concurrent.ExecutorService executorService)Sets the executor service to use when startThread is true.Tailer.BuildersetReOpen(boolean reOpen)Sets the re-open behavior.Tailer.BuildersetStartThread(boolean startThread)Sets the daemon thread startup behavior.Tailer.BuildersetTailable(Tailer.Tailable tailable)Sets the tailable.Tailer.BuildersetTailerListener(TailerListener tailerListener)Sets the listener.Tailer.BuildersetTailFromEnd(boolean end)Sets the tail start behavior.-
Methods inherited from class org.apache.commons.io.build.AbstractStreamBuilder
getCharset, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeMax, setCharset, setCharset, setOpenOptions
-
Methods inherited from class org.apache.commons.io.build.AbstractOriginSupplier
setByteArray, setCharSequence, setFile, setFile, setInputStream, setOutputStream, setPath, setPath, setReader, setURI, setWriter
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.io.function.IOSupplier
asSupplier
-
-
-
-
Method Detail
-
get
public Tailer get()
Builds a newTailer.This builder use the following aspects:
AbstractStreamBuilder.getBufferSize()AbstractStreamBuilder.getCharset()Tailer.TailableTailerListener- delayDuration
- tailFromEnd
- reOpen
- Returns:
- a new instance.
-
setDelayDuration
public Tailer.Builder setDelayDuration(java.time.Duration delayDuration)
Sets the delay duration. null resets to the default delay of one second.- Parameters:
delayDuration- the delay between checks of the file for new content.- Returns:
- this
-
setExecutorService
public Tailer.Builder setExecutorService(java.util.concurrent.ExecutorService executorService)
Sets the executor service to use when startThread is true.- Parameters:
executorService- the executor service to use when startThread is true.- Returns:
- this
-
setReOpen
public Tailer.Builder setReOpen(boolean reOpen)
Sets the re-open behavior.- Parameters:
reOpen- whether to close/reopen the file between chunks- Returns:
- this
-
setStartThread
public Tailer.Builder setStartThread(boolean startThread)
Sets the daemon thread startup behavior.- Parameters:
startThread- whether to create a daemon thread automatically.- Returns:
- this
-
setTailable
public Tailer.Builder setTailable(Tailer.Tailable tailable)
Sets the tailable.- Parameters:
tailable- the tailable.- Returns:
- this.
-
setTailerListener
public Tailer.Builder setTailerListener(TailerListener tailerListener)
Sets the listener.- Parameters:
tailerListener- the listener.- Returns:
- this
-
setTailFromEnd
public Tailer.Builder setTailFromEnd(boolean end)
Sets the tail start behavior.- Parameters:
end- Set to true to tail from the end of the file, false to tail from the beginning of the file.- Returns:
- this
-
-