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 new `Tailer`.

  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();

  See Also:
    `get()`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Builder()` Constructs a new builder of `Tailer`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Tailer` | `get()` Builds a new `Tailer`.
    `Tailer.Builder` | `setDelayDuration(java.time.Duration delayDuration)` Sets the delay duration.
    `Tailer.Builder` | `setExecutorService(ExecutorService executorService)` Sets the executor service to use when startThread is true.
    `Tailer.Builder` | `setIgnoreTouch(boolean ignoreTouch)` Sets whether a change in timestamp causes the file to be re-read.
    `protected Tailer.Builder` | `setOrigin(AbstractOrigin<?,?> origin)` Sets the origin.
    `Tailer.Builder` | `setReOpen(boolean reOpen)` Sets the re-open behavior.
    `Tailer.Builder` | `setStartThread(boolean startThread)` Sets the daemon thread startup behavior.
    `Tailer.Builder` | `setTailable(Tailer.Tailable tailable)` Sets the tailable.
    `Tailer.Builder` | `setTailerListener(TailerListener tailerListener)` Sets the listener.
    `Tailer.Builder` | `setTailFromEnd(boolean end)` Sets the tail start behavior.

    - ### Methods inherited from class org.apache.commons.io.build.AbstractStreamBuilder

      `getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getFile, getInputStream, getOpenOptions, getOutputStream, getPath, getRandomAccessFile, getReader, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptions`

    - ### Methods inherited from class org.apache.commons.io.build.AbstractOriginSupplier

      `checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newRandomAccessFileOrigin, newRandomAccessFileOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOutputStream, setPath, setPath, setRandomAccessFile, setRandomAccessFile, setReader, setURI, setWriter`

    - ### Methods inherited from class org.apache.commons.io.build.AbstractSupplier

      `asThis`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.io.function.IOSupplier

      `asSupplier, getUnchecked`

- - ### Constructor Detail

    - #### Builder

          public Builder()

      Constructs a new builder of `Tailer`.

  - ### Method Detail

    - #### get

          public Tailer get()

      Builds a new `Tailer`.

      This builder uses the following aspects:

      - `AbstractStreamBuilder.getBufferSize()`
      - `AbstractStreamBuilder.getCharset()`
      - `Tailer.Tailable`
      - `TailerListener`
      - delayDuration
      - tailFromEnd
      - reOpen
      Returns:
        a new instance.
      See Also:
        `IOSupplier.getUnchecked()`

    - #### 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` instance.

    - #### setExecutorService

          public Tailer.Builder setExecutorService(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` instance.

    - #### setIgnoreTouch

          public Tailer.Builder setIgnoreTouch(boolean ignoreTouch)

      Sets whether a change in timestamp causes the file to be re-read.

      Useful when your watched file gets touched (the timestamps is more recent without changing the file) or when a file system updates a timestamp before a file's content. The default (false) re-reads the current file, while true does nothing.

      Parameters:
        `ignoreTouch` - Whether a change in timestamp causes the file to be re-read.
      Returns:
        `this` instance.

    - #### setOrigin

          protected Tailer.Builder setOrigin(AbstractOrigin<?,?> origin)

      Sets the origin.
      Overrides:
        `setOrigin` in class `AbstractOriginSupplier<Tailer,Tailer.Builder>`
      Parameters:
        `origin` - the new origin.
      Returns:
        `this` instance.
      Throws:
        `UnsupportedOperationException` - if the origin cannot be converted to a Path.

    - #### setReOpen

          public Tailer.Builder setReOpen(boolean reOpen)

      Sets the re-open behavior.
      Parameters:
        `reOpen` - whether to close/reopen the file between chunks
      Returns:
        `this` instance.

    - #### setStartThread

          public Tailer.Builder setStartThread(boolean startThread)

      Sets the daemon thread startup behavior.
      Parameters:
        `startThread` - whether to create a daemon thread automatically.
      Returns:
        `this` instance.

    - #### setTailable

          public Tailer.Builder setTailable(Tailer.Tailable tailable)

      Sets the tailable.
      Parameters:
        `tailable` - the tailable.
      Returns:
        `this` instance.

    - #### setTailerListener

          public Tailer.Builder setTailerListener(TailerListener tailerListener)

      Sets the listener.
      Parameters:
        `tailerListener` - the listener.
      Returns:
        `this` instance.

    - #### 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` instance.